Skip to content

Commit

Permalink
Merge pull request #4 from FGadvancer/main
Browse files Browse the repository at this point in the history
feat: add c++/c interface to core
  • Loading branch information
FGadvancer authored Dec 4, 2023
2 parents 52546fc + 276e290 commit 2f6226c
Show file tree
Hide file tree
Showing 20 changed files with 3,338 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.associations": {
"ostream": "cpp",
"chrono": "cpp",
"thread": "cpp"
},
"C_Cpp.errorSquiggles": "disabled"
}
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
5 changes: 5 additions & 0 deletions c_cpp_wrapper/build_dll.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o openimsdk.dll export.go constant.go protocol.go tools.go



g++ -shared -fPIC -o openimsdkcc.dll openimsdkcc.cc openimsdk.dll
2 changes: 2 additions & 0 deletions c_cpp_wrapper/build_run_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gcc -o test.exe -L. openimsdk.dll test.c
test.exe
9 changes: 9 additions & 0 deletions c_cpp_wrapper/build_so.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

rm ./openimsdk.so ./openimsdk.h
go build -buildmode=c-shared -trimpath -ldflags="-s -w" -o openimsdk.so export.go constant.go protocol.go tools.go


# build cpp sdk
rm ./openimsdkcc.so
g++ -fPIC -shared -o openimsdkcc.so openimsdkcc.cc ./openimsdk.so
1 change: 1 addition & 0 deletions c_cpp_wrapper/build_test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gcc -o test.exe -L. openimsdk.dll test.c
77 changes: 77 additions & 0 deletions c_cpp_wrapper/constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
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
)
1 change: 1 addition & 0 deletions c_cpp_wrapper/event_listener/listener.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package event_listener
Loading

0 comments on commit 2f6226c

Please sign in to comment.