feat: update sdk to v3.5.1 and refactor project structure.
This commit is contained in:
78
go/constant.go
Normal file
78
go/constant.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
var (
|
||||
NO_ERR = C.int(0)
|
||||
NO_ERR_MSG = C.CString("")
|
||||
NO_DATA = C.CString("")
|
||||
NO_PROGRESS = C.int(0)
|
||||
)
|
||||
|
||||
const (
|
||||
CONNECTING = iota
|
||||
CONNECT_SUCCESS
|
||||
CONNECT_FAILED
|
||||
KICKED_OFFLINE
|
||||
USER_TOKEN_EXPIRED
|
||||
JOINED_GROUP_ADDED
|
||||
JOINED_GROUP_DELETED
|
||||
GROUP_MEMBER_ADDED
|
||||
GROUP_MEMBER_DELETED
|
||||
GROUP_APPLICATION_ADDED
|
||||
GROUP_APPLICATION_DELETED
|
||||
GROUP_INFO_CHANGED
|
||||
GROUP_DISMISSED
|
||||
GROUP_MEMBER_INFO_CHANGED
|
||||
GROUP_APPLICATION_ACCEPTED
|
||||
GROUP_APPLICATION_REJECTED
|
||||
FRIEND_APPLICATION_ADDED
|
||||
FRIEND_APPLICATION_DELETED
|
||||
FRIEND_APPLICATION_ACCEPTED
|
||||
FRIEND_APPLICATION_REJECTED
|
||||
FRIEND_ADDED
|
||||
FRIEND_DELETED
|
||||
FRIEND_INFO_CHANGED
|
||||
BLACK_ADDED
|
||||
BLACK_DELETED
|
||||
SYNC_SERVER_START
|
||||
SYNC_SERVER_FINISH
|
||||
SYNC_SERVER_PROGRESS
|
||||
SYNC_SERVER_FAILED
|
||||
NEW_CONVERSATION
|
||||
CONVERSATION_CHANGED
|
||||
TOTAL_UNREAD_MESSAGE_COUNT_CHANGED
|
||||
RECV_NEW_MESSAGE
|
||||
RECV_C2C_READ_RECEIPT
|
||||
RECV_GROUP_READ_RECEIPT
|
||||
NEW_RECV_MESSAGE_REVOKED
|
||||
RECV_MESSAGE_EXTENSIONS_CHANGED
|
||||
RECV_MESSAGE_EXTENSIONS_DELETED
|
||||
RECV_MESSAGE_EXTENSIONS_ADDED
|
||||
RECV_OFFLINE_NEW_MESSAGE
|
||||
MSG_DELETED
|
||||
|
||||
RECV_NEW_MESSAGES
|
||||
RECV_OFFLINE_NEW_MESSAGES
|
||||
|
||||
SELF_INFO_UPDATED
|
||||
USER_STATUS_CHANGED
|
||||
|
||||
RECV_CUSTOM_BUSINESS_MESSAGE
|
||||
|
||||
MESSAGE_KV_INFO_CHANGED
|
||||
|
||||
UPLOAD_FILE_CALLBACK_OPEN
|
||||
UPLOAD_FILE_CALLBACK_PART_SIZE
|
||||
UPLOAD_FILE_CALLBACK_HASH_PART_PROGRESS
|
||||
UPLOAD_FILE_CALLBACK_HASH_PART_COMPLETE
|
||||
UPLOAD_FILE_CALLBACK_UPLOAD_ID
|
||||
UPLOAD_FILE_CALLBACK_UPLOAD_PART_COMPLETE
|
||||
UPLOAD_FILE_CALLBACK_UPLOAD_COMPLETE
|
||||
UPLOAD_FILE_CALLBACK_COMPLETE
|
||||
CONVERSATION_USER_INPUT_STATUS_CHANGED
|
||||
RECV_ONLINE_ONLY_MESSAGE
|
||||
)
|
||||
1186
go/export.go
Normal file
1186
go/export.go
Normal file
File diff suppressed because it is too large
Load Diff
79
go/go.sum
Normal file
79
go/go.sum
Normal file
@@ -0,0 +1,79 @@
|
||||
github.com/OpenIMSDK/protocol v0.0.40 h1:1/Oij6RSAaePCPrWGwp9Cyz976/8Uxr94hM5M5FXzlg=
|
||||
github.com/OpenIMSDK/protocol v0.0.40/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||
github.com/OpenIMSDK/tools v0.0.24 h1:P8n7ZtsZEbm4W3dQAem29O+bigzy6YPXxFzd/D8Vh3U=
|
||||
github.com/OpenIMSDK/tools v0.0.24/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
|
||||
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
|
||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
|
||||
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4=
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
||||
github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ=
|
||||
github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
|
||||
github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0=
|
||||
github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/openimsdk/openim-sdk-core/v3 v3.5.1 h1:lvC8TlouT9zFxjoBeH/S4YCkwbQ5IgSnNRO9NJ9H5v8=
|
||||
github.com/openimsdk/openim-sdk-core/v3 v3.5.1/go.mod h1:d2aVHT6pSYthQQd+/4JaruHPTLsQV2D+eQisRQkoP3I=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
||||
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
|
||||
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
|
||||
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
|
||||
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
|
||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230717213848-3f92550aa753 h1:XUODHrpzJEUeWmVo/jfNTLj0YyVveOo28oE6vkFbkO4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230717213848-3f92550aa753/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
|
||||
google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI=
|
||||
google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gorm.io/driver/sqlite v1.3.6 h1:Fi8xNYCUplOqWiPa3/GuCeowRNBRGTf62DEmhMDHeQQ=
|
||||
gorm.io/driver/sqlite v1.3.6/go.mod h1:Sg1/pvnKtbQ7jLXxfZa+jSHvoX8hoZA8cn4xllOMTgE=
|
||||
gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE=
|
||||
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
|
||||
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
||||
106
go/protocol.go
Normal file
106
go/protocol.go
Normal file
@@ -0,0 +1,106 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
typedef void (*CB_S)(char *);
|
||||
typedef void (*CB_I_S)(int,char *);
|
||||
typedef void (*CB_S_I_S_S)(char *,int,char *,char *);
|
||||
typedef void (*CB_S_I_S_S_I)(char *,int,char *,char *,int);
|
||||
|
||||
CB_S DebugPrint;
|
||||
|
||||
void Call_CB_S(CB_S func,char* data)
|
||||
{
|
||||
if(func == NULL){
|
||||
printf("callback func is null\n");
|
||||
return;
|
||||
}
|
||||
func(data);
|
||||
}
|
||||
|
||||
|
||||
void Call_CB_I_S(CB_I_S func,int event,char* data)
|
||||
{
|
||||
if(func == NULL){
|
||||
printf("callback func is null\n");
|
||||
return;
|
||||
}
|
||||
if (strcmp(data, "\"\"") == 0) {
|
||||
strcpy(data, "");
|
||||
}
|
||||
func(event,data);
|
||||
if (data != NULL && data[0] != '\0')
|
||||
{
|
||||
printf("this is not null data event\n");
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
void Call_CB_S_I_S_S(CB_S_I_S_S func,char* operationID, int errCode,char* errMsg,char* data)
|
||||
{
|
||||
if(func == NULL){
|
||||
printf("callback func is null\n");
|
||||
return;
|
||||
}
|
||||
if (strcmp(data, "\"\"") == 0) {
|
||||
strcpy(data, "");
|
||||
}
|
||||
if (strlen(errMsg) != 0 && errMsg[strlen(errMsg) - 1] != '\0') {
|
||||
printf("ttttt %s\n",errMsg);
|
||||
strncat(errMsg, "\0", 1);
|
||||
}
|
||||
func(operationID,errCode,errMsg,data);
|
||||
if (errMsg != NULL && errMsg[0] != '\0')
|
||||
{
|
||||
printf("this is not null errmsg %s\n",errMsg);
|
||||
free(errMsg);
|
||||
}
|
||||
if (data != NULL && data[0] != '\0')
|
||||
{
|
||||
printf("this is not null data base,opid:%s,data:%s\n",operationID,data);
|
||||
free(data);
|
||||
}
|
||||
if (operationID != NULL)
|
||||
{
|
||||
printf("this is not null operationID:%s\n",operationID);
|
||||
free(operationID);
|
||||
}
|
||||
}
|
||||
void Call_CB_S_I_S_S_I(CB_S_I_S_S_I func,char* operationID,int errCode,char* errMsg,char* data,int progress)
|
||||
{
|
||||
if(func == NULL){
|
||||
printf("callback func is null\n");
|
||||
return;
|
||||
}
|
||||
if(strcmp(data, "\"\"") == 0) {
|
||||
strcpy(data, "");
|
||||
}
|
||||
func(operationID,errCode,errMsg,data,progress);
|
||||
if (errMsg != NULL && errMsg[0] != '\0')
|
||||
{
|
||||
printf("this is not null errmsg\n");
|
||||
free(errMsg);
|
||||
}
|
||||
if (data != NULL && data[0] != '\0')
|
||||
{
|
||||
printf("this is not null data\n");
|
||||
free(data);
|
||||
}
|
||||
if (operationID != NULL)
|
||||
{
|
||||
printf("this is not null operationID\n");
|
||||
free(operationID);
|
||||
}
|
||||
}
|
||||
|
||||
enum CONN_EVENT{
|
||||
CONNECTING,
|
||||
CONNECT_SUCCESS,
|
||||
CONNECT_FAILED,
|
||||
KICKED_OFFLINE,
|
||||
USER_TOKEN_EXPIRED
|
||||
|
||||
};
|
||||
*/
|
||||
import "C"
|
||||
32
go/tools.go
Normal file
32
go/tools.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func parseBool(b int) bool {
|
||||
return !(b == 0)
|
||||
}
|
||||
|
||||
func StructToJsonString(param interface{}) string {
|
||||
dataType, _ := json.Marshal(param)
|
||||
dataString := string(dataType)
|
||||
return dataString
|
||||
}
|
||||
|
||||
func FreeCString(strList ...*C.char) {
|
||||
for _, str := range strList {
|
||||
C.free(unsafe.Pointer(str))
|
||||
}
|
||||
}
|
||||
func Int32ToString(intValue int32) string {
|
||||
return strconv.Itoa(int(intValue))
|
||||
}
|
||||
Reference in New Issue
Block a user