feat: add init sdk and login test.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
This commit is contained in:
parent
5dace36823
commit
c2d7b57853
@ -1 +1 @@
|
||||
go build -buildmode=c-shared -o c_wrapper.dll export.go
|
||||
go build -buildmode=c-shared -o c_wrapper.dll c_init_login.go export.go
|
@ -5,18 +5,12 @@ package main
|
||||
|
||||
typedef void (*base_func)();
|
||||
typedef void (*err_func)(int,void *);
|
||||
typedef void (*success_func)(char *);
|
||||
|
||||
extern base_func _onConnecting;
|
||||
extern base_func _onConnectSuccess;
|
||||
extern base_func _onKickedOffline;
|
||||
extern base_func _onUserTokenExpired;
|
||||
extern err_func _onConnectFailed;
|
||||
|
||||
extern void c_onConnecting();
|
||||
extern void c_onConnectSuccess();
|
||||
extern void c_onKickedOffline();
|
||||
extern void c_onUserTokenExpired();
|
||||
extern void c_onConnectFailed(int ,void*);
|
||||
extern void c_base_caller(base_func func);
|
||||
extern void c_err_caller(err_func func,int ,void*);
|
||||
extern void c_success_caller(success_func func,char* data);
|
||||
|
||||
|
||||
*/
|
||||
@ -36,9 +30,16 @@ func init_sdk(onConnecting C.base_func,
|
||||
callback := NewConnCallback(onConnecting, onConnectSuccess, onKickedOffline, onUserTokenExpired, onConnectFailed)
|
||||
return open_im_sdk.InitSDK(callback, C.GoString(operationID), C.GoString(config))
|
||||
}
|
||||
// func main() {
|
||||
|
||||
// }
|
||||
//export login
|
||||
func login(successFunc C.success_func, failedFunc C.err_func, operationID, uid, token *C.char) {
|
||||
baseCallback := NewBaseCallback(successFunc, failedFunc)
|
||||
open_im_sdk.Login(baseCallback, C.GoString(operationID), C.GoString(uid), C.GoString(token))
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
|
||||
type ConnCallback struct {
|
||||
onConnecting C.base_func
|
||||
@ -55,26 +56,39 @@ func NewConnCallback(onConnecting C.base_func, onConnectSuccess C.base_func,
|
||||
}
|
||||
|
||||
func (c ConnCallback) OnConnecting() {
|
||||
C._onConnecting = c.onConnecting
|
||||
C.c_onConnecting()
|
||||
C.c_base_caller(c.onConnecting)
|
||||
}
|
||||
|
||||
func (c ConnCallback) OnConnectSuccess() {
|
||||
C._onConnectSuccess = c.onConnectSuccess
|
||||
C.c_onConnectSuccess()
|
||||
C.c_base_caller(c.onConnectSuccess)
|
||||
}
|
||||
|
||||
func (c ConnCallback) OnConnectFailed(errCode int32, errMsg string) {
|
||||
C._onConnectFailed = c.onConnectFailed
|
||||
C.c_onConnectFailed(C.int(errCode), unsafe.Pointer(C.CString(errMsg)))
|
||||
C.c_err_caller(c.onConnectFailed, C.int(errCode), unsafe.Pointer(C.CString(errMsg)))
|
||||
|
||||
}
|
||||
|
||||
func (c ConnCallback) OnKickedOffline() {
|
||||
C._onKickedOffline = c.onKickedOffline
|
||||
C.c_onKickedOffline()
|
||||
C.c_base_caller(c.onKickedOffline)
|
||||
}
|
||||
|
||||
func (c ConnCallback) OnUserTokenExpired() {
|
||||
C._onUserTokenExpired = c.onUserTokenExpired
|
||||
C.c_onUserTokenExpired()
|
||||
C.c_base_caller(c.onUserTokenExpired)
|
||||
}
|
||||
|
||||
type BaseCallback struct {
|
||||
successFunc C.success_func
|
||||
failedFunc C.err_func
|
||||
}
|
||||
|
||||
func NewBaseCallback(successFunc C.success_func, failedFunc C.err_func) *BaseCallback {
|
||||
return &BaseCallback{successFunc: successFunc, failedFunc: failedFunc}
|
||||
}
|
||||
|
||||
func (b BaseCallback) OnError(errCode int32, errMsg string) {
|
||||
C.c_err_caller(b.failedFunc, C.int(errCode), unsafe.Pointer(C.CString(errMsg)))
|
||||
}
|
||||
|
||||
func (b BaseCallback) OnSuccess(data string) {
|
||||
C.c_success_caller(b.successFunc, C.CString(data))
|
||||
}
|
||||
|
@ -1,13 +1,22 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
typedef void (*base_func)();
|
||||
typedef void (*err_func)(int,void *);
|
||||
typedef void (*success_func)(char *);
|
||||
|
||||
void c_base_caller(base_func func)
|
||||
{
|
||||
func();
|
||||
}
|
||||
void c_err_caller(err_func func,int errCode,void* errMsg)
|
||||
{
|
||||
func(errCode,errMsg);
|
||||
}
|
||||
void c_success_caller(success_func func,char* data)
|
||||
{
|
||||
func(data);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import "fmt"
|
||||
|
||||
//export Init_SDK
|
||||
func Init_SDK() {
|
||||
fmt.Println("Init SDK")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,65 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "c_wrapper.h"
|
||||
|
||||
#include "c_wrapper.h"
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
GoUint32 platformID;
|
||||
char apiAddr[256];
|
||||
char wsAddr[256];
|
||||
char dataDir[256];
|
||||
GoUint32 logLevel;
|
||||
GoUint8 isLogStandardOutput;
|
||||
char logFilePath[256];
|
||||
GoUint8 isExternalExtensions;
|
||||
} IMConfigC;
|
||||
|
||||
|
||||
void on_connecting()
|
||||
{
|
||||
printf("on_connecting\n");
|
||||
}
|
||||
void on_connect_success()
|
||||
{
|
||||
printf("on_connect_success\n");
|
||||
}
|
||||
void on_kick_offline()
|
||||
{
|
||||
printf("on_kick_offline\n");
|
||||
}
|
||||
void on_user_token_expired()
|
||||
{
|
||||
printf("on_user_token_expired\n");
|
||||
}
|
||||
void on_connect_failed(int err_code,void * err_msg)
|
||||
{
|
||||
char* message = (char*)err_msg;
|
||||
printf("Error code: %d\n", err_code);
|
||||
printf("Error message: %s\n", message);
|
||||
}
|
||||
void success(char * data)
|
||||
{
|
||||
printf("login success : %s\n", data);
|
||||
}
|
||||
void main(int argc, char **argv)
|
||||
{
|
||||
Init_SDK();
|
||||
char operationID[] = "12345";
|
||||
char uid[] = "6959062403";
|
||||
char token[] = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiI2OTU5MDYyNDAzIiwiUGxhdGZvcm1JRCI6MywiZXhwIjoxNzAwNzIwOTg0LCJuYmYiOjE2OTI5NDQ2ODQsImlhdCI6MTY5Mjk0NDk4NH0.8otKTFrOCs8_ueV10rNOD-rzHrCT_EN0obKS9q79bIc";
|
||||
|
||||
|
||||
char* jsonString = "{\"platformID\": 3, \"apiAddr\": \"http://125.124.195.201:10002\", \"wsAddr\":\"ws://125.124.195.201:10001\",\"dataDir\": \"./\", \"logLevel\": 5, \"isLogStandardOutput\": true, \"logFilePath\": \"./\", \"isExternalExtensions\": true}";
|
||||
|
||||
GoUint8 init_result;
|
||||
init_result=init_sdk(on_connecting, on_connect_success, on_kick_offline, on_user_token_expired,on_connect_failed, operationID, jsonString);
|
||||
printf("init_result: %u\n", init_result);
|
||||
|
||||
login(success,on_connect_failed,operationID,uid,token);
|
||||
|
||||
sleep(1000000);
|
||||
|
||||
}
|
185
internal/login/empty_listener.go
Normal file
185
internal/login/empty_listener.go
Normal file
@ -0,0 +1,185 @@
|
||||
package login
|
||||
|
||||
type emptyGroupListener struct{}
|
||||
|
||||
func newEmptyGroupListener() *emptyGroupListener {
|
||||
return &emptyGroupListener{}
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnJoinedGroupAdded(groupInfo string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnJoinedGroupDeleted(groupInfo string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupMemberAdded(groupMemberInfo string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupMemberDeleted(groupMemberInfo string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupApplicationAdded(groupApplication string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupApplicationDeleted(groupApplication string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupInfoChanged(groupInfo string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupDismissed(groupInfo string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupMemberInfoChanged(groupMemberInfo string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupApplicationAccepted(groupApplication string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyGroupListener) OnGroupApplicationRejected(groupApplication string) {
|
||||
|
||||
}
|
||||
|
||||
type emptyFriendshipListener struct{}
|
||||
|
||||
func newEmptyFriendshipListener() *emptyFriendshipListener {
|
||||
return &emptyFriendshipListener{}
|
||||
}
|
||||
|
||||
func (emptyFriendshipListener) OnFriendApplicationAdded(friendApplication string) {}
|
||||
|
||||
func (emptyFriendshipListener) OnFriendApplicationDeleted(friendApplication string) {}
|
||||
|
||||
func (emptyFriendshipListener) OnFriendApplicationAccepted(friendApplication string) {}
|
||||
|
||||
func (emptyFriendshipListener) OnFriendApplicationRejected(friendApplication string) {}
|
||||
|
||||
func (emptyFriendshipListener) OnFriendAdded(friendInfo string) {}
|
||||
|
||||
func (emptyFriendshipListener) OnFriendDeleted(friendInfo string) {}
|
||||
|
||||
func (emptyFriendshipListener) OnFriendInfoChanged(friendInfo string) {}
|
||||
|
||||
func (emptyFriendshipListener) OnBlackAdded(blackInfo string) {}
|
||||
|
||||
func (emptyFriendshipListener) OnBlackDeleted(blackInfo string) {}
|
||||
|
||||
type emptyConversationListener struct{}
|
||||
|
||||
func newEmptyConversationListener() *emptyConversationListener {
|
||||
return &emptyConversationListener{}
|
||||
}
|
||||
|
||||
func (emptyConversationListener) OnSyncServerStart() {
|
||||
|
||||
}
|
||||
|
||||
func (emptyConversationListener) OnSyncServerFinish() {
|
||||
|
||||
}
|
||||
|
||||
func (emptyConversationListener) OnSyncServerFailed() {
|
||||
|
||||
}
|
||||
|
||||
func (emptyConversationListener) OnNewConversation(conversationList string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyConversationListener) OnConversationChanged(conversationList string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyConversationListener) OnTotalUnreadMessageCountChanged(totalUnreadCount int32) {
|
||||
|
||||
}
|
||||
|
||||
type emptyAdvancedMsgListener struct{}
|
||||
|
||||
func newEmptyAdvancedMsgListener() *emptyAdvancedMsgListener {
|
||||
return &emptyAdvancedMsgListener{}
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnRecvNewMessage(message string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnRecvC2CReadReceipt(msgReceiptList string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnRecvGroupReadReceipt(groupMsgReceiptList string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnNewRecvMessageRevoked(messageRevoked string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnRecvMessageExtensionsChanged(msgID string, reactionExtensionList string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnRecvMessageExtensionsDeleted(msgID string, reactionExtensionKeyList string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnRecvMessageExtensionsAdded(msgID string, reactionExtensionList string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnRecvOfflineNewMessage(message string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyAdvancedMsgListener) OnMsgDeleted(message string) {
|
||||
|
||||
}
|
||||
|
||||
type emptyBatchMsgListener struct{}
|
||||
|
||||
func newEmptyBatchMsgListener() *emptyBatchMsgListener {
|
||||
return &emptyBatchMsgListener{}
|
||||
}
|
||||
|
||||
func (emptyBatchMsgListener) OnRecvNewMessages(messageList string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyBatchMsgListener) OnRecvOfflineNewMessages(messageList string) {
|
||||
|
||||
}
|
||||
|
||||
type emptyUserListener struct{}
|
||||
|
||||
func newEmptyUserListener() *emptyUserListener {
|
||||
return &emptyUserListener{}
|
||||
}
|
||||
|
||||
func (emptyUserListener) OnSelfInfoUpdated(userInfo string) {
|
||||
|
||||
}
|
||||
|
||||
func (emptyUserListener) OnUserStatusChanged(statusMap string) {
|
||||
|
||||
}
|
||||
|
||||
type emptyCustomBusinessListener struct{}
|
||||
|
||||
func newEmptyCustomBusinessListener() *emptyCustomBusinessListener {
|
||||
return &emptyCustomBusinessListener{}
|
||||
}
|
||||
|
||||
func (emptyCustomBusinessListener) OnRecvCustomBusinessMessage(businessMessage string) {
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user