You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openim-sdk-cpp/c_wrapper/test.c

66 lines
1.7 KiB

// gcc -o test.exe -lc_wrapper.dll test.c
#include <stdio.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)
{
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);
}