Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add c++/c interface to core #4

Merged
merged 40 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4653f35
feat: add dll interface.
FGadvancer Aug 29, 2023
4bc14a9
feat: add dll interface.
FGadvancer Aug 29, 2023
7404a54
feat: add dll interface.
FGadvancer Aug 29, 2023
5dace36
test c_wrapper
yj12138 Aug 30, 2023
c2d7b57
feat: add init sdk and login test.
FGadvancer Aug 30, 2023
8968c1f
delete c_init_login.go
yj12138 Aug 30, 2023
e65f192
rename
yj12138 Aug 30, 2023
e442c41
feat: add bat of gen android's so.
FGadvancer Aug 30, 2023
3059227
feat: add create message c interface.
FGadvancer Aug 30, 2023
d76c22e
feat: add create message c interface.
FGadvancer Aug 31, 2023
0ffe9bb
update build_dll.bat
yj12138 Sep 1, 2023
d8c3e11
chore: change generate so file name.
FGadvancer Sep 1, 2023
9b418a8
fix: modify the way of communication from C to Go.
FGadvancer Sep 3, 2023
9648dae
fix: modify the way of communication from C to Go.
FGadvancer Sep 3, 2023
4478477
fix: modify the way of communication from C to Go.
FGadvancer Sep 3, 2023
1c41cd0
fix: modify the way of communication from C to Go.
FGadvancer Sep 3, 2023
ba502b2
fix: modify the way of communication from C to Go.
FGadvancer Sep 3, 2023
3d8d7a8
fix: c free char * after call go.
FGadvancer Sep 4, 2023
a57eef1
fix: remove free c free func.
FGadvancer Sep 4, 2023
af39356
fix: add conversation and get history message func.
FGadvancer Sep 5, 2023
3203eb8
test: c test func update.
FGadvancer Sep 6, 2023
1434d5d
test: c test func update.
FGadvancer Sep 6, 2023
f7f1d48
feat: add c func of user friend and group.
FGadvancer Sep 6, 2023
2943d78
fix: recycle memory when callback finish.
FGadvancer Sep 7, 2023
c4fafed
fix: provide the corresponding relationship when the function is call…
FGadvancer Sep 11, 2023
2da933c
fix: add listener interface.
FGadvancer Sep 11, 2023
4d05aca
style: change length of func.
FGadvancer Sep 11, 2023
eac43b8
feat: add sh of generate ios dylib.
FGadvancer Sep 12, 2023
c2940b3
feat: add sh of generate ios dylib.
FGadvancer Sep 12, 2023
c4f4d04
fix: calback and test file update
FGadvancer Sep 16, 2023
314328c
fix: properly releasing C memory to avoid double-freeing
FGadvancer Sep 16, 2023
2ee9b33
fix: create message free string
FGadvancer Sep 17, 2023
43d7d4e
set_print
yj12138 Sep 17, 2023
50ac591
set_print
yj12138 Sep 17, 2023
c3c89e4
fix: remove free c string.
FGadvancer Sep 17, 2023
9bd3e33
refactor: cons merge into a enum.
FGadvancer Sep 23, 2023
eb65aff
fix: batch message listener remove.
FGadvancer Sep 24, 2023
0f78cee
feat: impl rest oncallback in export.go
CNCSMonster Dec 3, 2023
658e3f3
feat: impl cpp wrapper
CNCSMonster Dec 3, 2023
276e290
feat: add sh for compile dll from cpp wrapper
CNCSMonster Dec 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading