├── .gitignore
├── LICENSE
├── call_push_test
├── CMakeLists.txt
├── build.sh
└── call_push_test.cpp
├── clientdemo
├── .classpath
├── .project
├── AndroidManifest.xml
├── ic_launcher-web.png
├── jni
│ ├── Android.mk
│ ├── Application.mk
│ ├── android
│ │ ├── androidclient.cpp
│ │ ├── androidclient.h
│ │ ├── client_jni.cpp
│ │ └── client_jni.h
│ ├── client_sdk
│ │ ├── cli_test.cpp
│ │ ├── client.cpp
│ │ ├── client.h
│ │ ├── client_conn.cpp
│ │ ├── client_conn.h
│ │ ├── client_def.h
│ │ ├── client_log.h
│ │ ├── err_no.h
│ │ ├── eventloop.cpp
│ │ ├── eventloop.h
│ │ ├── logic_common.cpp
│ │ ├── logic_common.h
│ │ ├── msg_head.h
│ │ ├── opbase.cpp
│ │ ├── opbase.h
│ │ ├── ops.cpp
│ │ ├── ops.h
│ │ ├── service_type.h
│ │ └── srv_test.cpp
│ ├── common
│ │ ├── ef_aes.cpp
│ │ ├── ef_aes.h
│ │ ├── ef_auto_ptr.h
│ │ ├── ef_base64.cpp
│ │ ├── ef_base64.h
│ │ ├── ef_btype.h
│ │ ├── ef_hex.cpp
│ │ ├── ef_hex.h
│ │ ├── ef_loop_buf.cpp
│ │ ├── ef_loop_buf.h
│ │ ├── ef_md5.cpp
│ │ ├── ef_md5.h
│ │ ├── ef_no_copy.h
│ │ ├── ef_singleton.h
│ │ ├── ef_sock.cpp
│ │ ├── ef_sock.h
│ │ ├── ef_thread.cpp
│ │ ├── ef_thread.h
│ │ ├── ef_utility.cpp
│ │ ├── ef_utility.h
│ │ ├── err_no.h
│ │ ├── rijndael-alg-fst.cpp
│ │ ├── rijndael-alg-fst.h
│ │ ├── rijndael-api-fst.cpp
│ │ └── rijndael-api-fst.h
│ ├── config.h
│ ├── google
│ │ └── protobuf
│ │ │ ├── extension_set.cc
│ │ │ ├── extension_set.h
│ │ │ ├── generated_enum_reflection.h
│ │ │ ├── generated_message_util.cc
│ │ │ ├── generated_message_util.h
│ │ │ ├── io
│ │ │ ├── coded_stream.cc
│ │ │ ├── coded_stream.h
│ │ │ ├── coded_stream_inl.h
│ │ │ ├── zero_copy_stream.cc
│ │ │ ├── zero_copy_stream.h
│ │ │ ├── zero_copy_stream_impl.h
│ │ │ ├── zero_copy_stream_impl_lite.cc
│ │ │ └── zero_copy_stream_impl_lite.h
│ │ │ ├── message_lite.cc
│ │ │ ├── message_lite.h
│ │ │ ├── package_info.h
│ │ │ ├── repeated_field.cc
│ │ │ ├── repeated_field.h
│ │ │ ├── stubs
│ │ │ ├── atomicops.h
│ │ │ ├── atomicops_internals_arm_gcc.h
│ │ │ ├── atomicops_internals_arm_qnx.h
│ │ │ ├── atomicops_internals_atomicword_compat.h
│ │ │ ├── atomicops_internals_macosx.h
│ │ │ ├── atomicops_internals_mips_gcc.h
│ │ │ ├── atomicops_internals_pnacl.h
│ │ │ ├── atomicops_internals_x86_gcc.cc
│ │ │ ├── atomicops_internals_x86_gcc.h
│ │ │ ├── common.cc
│ │ │ ├── common.h
│ │ │ ├── hash.h
│ │ │ ├── map-util.h
│ │ │ ├── once.cc
│ │ │ ├── once.h
│ │ │ ├── platform_macros.h
│ │ │ ├── stl_util.h
│ │ │ ├── template_util.h
│ │ │ └── type_traits.h
│ │ │ ├── wire_format_lite.cc
│ │ │ ├── wire_format_lite.h
│ │ │ └── wire_format_lite_inl.h
│ ├── json
│ │ ├── autolink.h
│ │ ├── config.h
│ │ ├── features.h
│ │ ├── forwards.h
│ │ ├── json.h
│ │ ├── json_batchallocator.h
│ │ ├── json_internalarray.inl
│ │ ├── json_internalmap.inl
│ │ ├── json_reader.cpp
│ │ ├── json_value.cpp
│ │ ├── json_valueiterator.inl
│ │ ├── json_writer.cpp
│ │ ├── reader.h
│ │ ├── sconscript
│ │ ├── value.h
│ │ └── writer.h
│ └── proto
│ │ ├── connect_server.pb.cc
│ │ ├── connect_server.pb.h
│ │ ├── connect_server.proto
│ │ ├── message.pb.cc
│ │ ├── message.pb.h
│ │ ├── message.proto
│ │ ├── pair.pb.cc
│ │ ├── pair.pb.h
│ │ ├── pair.proto
│ │ ├── peer_server.pb.cc
│ │ ├── peer_server.pb.h
│ │ ├── peer_server.proto
│ │ ├── session.pb.cc
│ │ ├── session.pb.h
│ │ └── session.proto
├── proguard-project.txt
├── project.properties
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── layout
│ │ └── activity_main.xml
│ ├── menu
│ │ └── main.xml
│ ├── values-w820dp
│ │ └── dimens.xml
│ └── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── src
│ └── com
│ └── gim
│ ├── MainActivity.java
│ ├── client.java
│ └── listener.java
├── common
├── CMakeLists.txt
├── build.sh
├── include
│ ├── cache_group.h
│ ├── dynamic_tokenchk.h
│ ├── ef_crypt.h
│ ├── log_init.h
│ ├── msg_db.h
│ ├── redis_msg_q.h
│ ├── server_status.h
│ ├── sess_cache.h
│ ├── token_checker.h
│ ├── tree.h
│ ├── zk_client.h
│ ├── zk_config.h
│ ├── zk_server_node.h
│ ├── zk_server_ob.h
│ └── zk_watcher.h
├── src
│ ├── cache_group.cpp
│ ├── def_cache_group.cpp
│ ├── def_cache_group.h
│ ├── def_sess_cache.cpp
│ ├── def_sess_cache.h
│ ├── def_sess_cache_group.cpp
│ ├── def_sess_cache_group.h
│ ├── dynamic_tokenchk.cpp
│ ├── ef_crypt.cpp
│ ├── gtype.h
│ ├── log_init.cpp
│ ├── message.pb.cpp
│ ├── msg_db.cpp
│ ├── pair.pb.cpp
│ ├── redis_cg.cpp
│ ├── redis_cg.h
│ ├── redis_client.cpp
│ ├── redis_client.h
│ ├── redis_msg_db.h
│ ├── redis_msg_q.cpp
│ ├── server_status.cpp
│ ├── sess_cache.cpp
│ ├── session.pb.cpp
│ ├── token_checker.cpp
│ ├── zk_client.cpp
│ ├── zk_config.cpp
│ ├── zk_server_node.cpp
│ ├── zk_server_ob.cpp
│ └── zk_watcher.cpp
└── test
│ ├── logtest
│ ├── CMakeLists.txt
│ ├── build.sh
│ ├── elog_test.cpp
│ └── log.conf
│ ├── msgboxtest
│ ├── CMakeLists.txt
│ ├── build.sh
│ ├── msgboxtest.cpp
│ └── test.conf
│ ├── redisclitest
│ ├── CMakeLists.txt
│ ├── build.sh
│ └── redis_cli_test.cpp
│ ├── sess_cache_test
│ ├── CMakeLists.txt
│ ├── build.sh
│ ├── log.conf
│ └── sess_cache_test.cpp
│ ├── sesstest
│ ├── CMakeLists.txt
│ ├── build.sh
│ ├── sess.conf
│ └── sess_test.cpp
│ ├── svlsttest
│ ├── CMakeLists.txt
│ ├── build.sh
│ ├── svlist.conf
│ └── svlst_test.cpp
│ └── zk_client_test
│ ├── CMakeLists.txt
│ ├── build.sh
│ ├── log.conf
│ └── test.cpp
├── connect_server
├── CMakeLists.txt
├── build.sh
├── etc
│ ├── elog.conf
│ └── settings.conf
├── src
│ ├── client_config.h
│ ├── client_conn.cpp
│ ├── client_conn.h
│ ├── common.cpp
│ ├── common.h
│ ├── connect_server.cpp
│ ├── connect_server.h
│ ├── main.cpp
│ ├── proto
│ │ ├── common_logic_service.proto
│ │ ├── connect_server.pb.cpp
│ │ ├── connect_server.pb.h
│ │ ├── connect_server.proto
│ │ ├── err_no.h
│ │ ├── message.proto
│ │ ├── msg_head.h
│ │ ├── pair.proto
│ │ ├── peer_server.proto
│ │ ├── position_server.proto
│ │ └── session.proto
│ ├── server_config.h
│ ├── type_map.cpp
│ └── type_map.h
├── test_client
│ ├── CMakeLists.txt
│ ├── build.sh
│ └── src
│ │ ├── proto
│ │ ├── common_logic_service.proto
│ │ ├── connect_server.pb.cpp
│ │ ├── connect_server.pb.h
│ │ ├── connect_server.proto
│ │ ├── err_no.h
│ │ ├── message.pb.cpp
│ │ ├── message.pb.h
│ │ ├── message.proto
│ │ ├── msg_head.h
│ │ ├── pair.pb.cpp
│ │ ├── pair.pb.h
│ │ ├── pair.proto
│ │ ├── peer_server.pb.cpp
│ │ ├── peer_server.pb.h
│ │ ├── peer_server.proto
│ │ ├── position_server.proto
│ │ └── session.proto
│ │ └── test.cpp
└── test_server
│ ├── CMakeLists.txt
│ ├── build.sh
│ └── src
│ ├── proto
│ ├── common_logic_service.proto
│ ├── connect_server.pb.cpp
│ ├── connect_server.pb.h
│ ├── connect_server.proto
│ ├── err_no.h
│ ├── message.proto
│ ├── msg_head.h
│ ├── pair.pb.cpp
│ ├── pair.pb.h
│ ├── pair.proto
│ ├── peer_server.proto
│ └── session.proto
│ └── test.cpp
├── dispatch_server
├── CMakeLists.txt
├── build.sh
├── etc
│ ├── ds.conf
│ ├── elog.conf
│ └── settings.conf
├── src
│ ├── client_conn.cpp
│ ├── client_conn.h
│ ├── common.cpp
│ ├── common.h
│ ├── common_logic_service.proto
│ ├── config.h
│ ├── connect_server.proto
│ ├── consv_config.h
│ ├── dispatch_server.cpp
│ ├── dispatch_server.h
│ ├── err_no.h
│ ├── main.cpp
│ ├── message.proto
│ ├── msg_head.h
│ ├── pair.proto
│ ├── proto
│ │ ├── common_logic_service.proto
│ │ ├── connect_server.pb.cpp
│ │ ├── connect_server.pb.h
│ │ ├── connect_server.proto
│ │ ├── err_no.h
│ │ ├── message.proto
│ │ ├── msg_head.h
│ │ ├── pair.pb.cpp
│ │ ├── pair.pb.h
│ │ ├── pair.proto
│ │ └── session.proto
│ └── session.proto
└── test
│ ├── CMakeLists.txt
│ ├── build.sh
│ └── src
│ ├── common_logic_service.proto
│ ├── connect_server.proto
│ ├── err_no.h
│ ├── main.cpp
│ ├── message.proto
│ ├── msg_head.h
│ ├── pair.proto
│ ├── proto
│ ├── common_logic_service.proto
│ ├── connect_server.pb.cpp
│ ├── connect_server.pb.h
│ ├── connect_server.proto
│ ├── err_no.h
│ ├── message.proto
│ ├── msg_head.h
│ ├── pair.pb.cpp
│ ├── pair.pb.h
│ ├── pair.proto
│ └── session.proto
│ └── session.proto
├── doc
├── GIM编码规范.doc
└── 架构设计.doc
├── efnfw
├── CMakeLists.txt
├── base
│ ├── ef_aes.cpp
│ ├── ef_aes.h
│ ├── ef_atomic.cpp
│ ├── ef_atomic.h
│ ├── ef_auto_ptr.h
│ ├── ef_base64.cpp
│ ├── ef_base64.h
│ ├── ef_btype.h
│ ├── ef_deamonize.cpp
│ ├── ef_deamonize.h
│ ├── ef_hex.cpp
│ ├── ef_hex.h
│ ├── ef_loader.h
│ ├── ef_log.cpp
│ ├── ef_log.h
│ ├── ef_loop_buf.cpp
│ ├── ef_loop_buf.h
│ ├── ef_md5.cpp
│ ├── ef_md5.h
│ ├── ef_no_copy.h
│ ├── ef_singleton.h
│ ├── ef_statistic.cpp
│ ├── ef_statistic.h
│ ├── ef_thread.cpp
│ ├── ef_thread.h
│ ├── ef_thread_pool.cpp
│ ├── ef_thread_pool.h
│ ├── ef_tsd_ptr.h
│ ├── ef_utility.cpp
│ ├── ef_utility.h
│ ├── rijndael-alg-fst.cpp
│ ├── rijndael-alg-fst.h
│ ├── rijndael-api-fst.cpp
│ └── rijndael-api-fst.h
├── build.sh
└── net
│ ├── ef_acceptor.cpp
│ ├── ef_acceptor.h
│ ├── ef_client.cpp
│ ├── ef_client.h
│ ├── ef_common.h
│ ├── ef_connection.cpp
│ ├── ef_connection.h
│ ├── ef_connector.h
│ ├── ef_device.cpp
│ ├── ef_device.h
│ ├── ef_event_loop.cpp
│ ├── ef_event_loop.h
│ ├── ef_net_log.cpp
│ ├── ef_net_log.h
│ ├── ef_net_settings.cpp
│ ├── ef_net_settings.h
│ ├── ef_operator.cpp
│ ├── ef_operator.h
│ ├── ef_server.cpp
│ ├── ef_server.h
│ ├── ef_sock.cpp
│ ├── ef_sock.h
│ ├── ef_timer.cpp
│ └── ef_timer.h
├── img
└── jiagou.png
├── logic_server
├── CMakeLists.txt
├── build.sh
├── dispatcher.cpp
├── dispatcher.h
├── logic_common.cpp
├── logic_common.h
├── logic_server.cpp
├── logic_server.h
├── rpc_client.cpp
├── rpc_client.h
├── server_conn.cpp
└── server_conn.h
├── logic_test
├── CMakeLists.txt
├── build.sh
├── etc
│ ├── elog.conf
│ └── settings.conf
└── src
│ ├── main.cpp
│ ├── test_conn.cpp
│ └── test_conn.h
├── proto
├── connect_server.proto
├── err_no.h
├── message.proto
├── msg_head.h
├── pair.proto
├── peer_server.proto
└── session.proto
├── push_server
├── CMakeLists.txt
├── build.sh
├── etc
│ └── elog.conf
├── run.sh
└── src
│ ├── main.cpp
│ ├── push_client_conn.cpp
│ ├── push_client_conn.h
│ ├── push_common.cpp
│ ├── push_common.h
│ ├── push_def.h
│ ├── push_msg_db.cpp
│ ├── push_msg_db.h
│ ├── push_server_conn.cpp
│ └── push_server_conn.h
└── thirdparty
├── jsoncpp-src-0.5.0.tar.gz
└── scons-2.1.0.tar.gz
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Precompiled Headers
8 | *.gch
9 | *.pch
10 |
11 | # Compiled Dynamic libraries
12 | *.so
13 | *.dylib
14 | *.dll
15 |
16 | # Fortran module files
17 | *.mod
18 |
19 | # Compiled Static libraries
20 | *.lai
21 | *.la
22 | *.a
23 | *.lib
24 |
25 | # Executables
26 | *.exe
27 | *.out
28 | *.app
29 |
--------------------------------------------------------------------------------
/call_push_test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(ConnectServer)
2 | set(CMAKE_VERBOSE_MAKEFILE ON)
3 | add_definitions("-Wall -pg -g")
4 | include_directories(${PROJECT_SOURCE_DIR}/../efnfw)
5 | link_directories(/usr/local/lib ../efnfw/lib)
6 | link_libraries(libefnfw.a jsoncpp pthread)
7 | file(GLOB_RECURSE SRC_LIST call_push_test.cpp)
8 | add_executable(bin/CallPushTest ${SRC_LIST})
9 |
--------------------------------------------------------------------------------
/call_push_test/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | cd ../efnfw;
4 | sh build.sh
5 | cd -
6 |
7 | cd ../common;
8 | sh build.sh
9 | cd -
10 |
11 | mkdir -p bin
12 |
13 | rm -fr CMakeCache.txt
14 | rm -fr CMakeFiles
15 |
16 |
17 | cmake .
18 | make clean;make
19 |
20 | rm -fr CMakeCache.txt
21 | rm -fr CMakeFiles
22 |
--------------------------------------------------------------------------------
/clientdemo/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/clientdemo/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | clientdemo
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 | org.eclipse.ui.externaltools.ExternalToolBuilder
30 | full,incremental,
31 |
32 |
33 | LaunchConfigHandle
34 | <project>/.externalToolBuilders/BBBBBBBBBBB.launch
35 |
36 |
37 |
38 |
39 |
40 | com.android.ide.eclipse.adt.AndroidNature
41 | org.eclipse.jdt.core.javanature
42 |
43 |
44 |
--------------------------------------------------------------------------------
/clientdemo/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/clientdemo/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmxiaocong/gim/f9bac9be3d2afdc9bea69d201d1ce3c10a56639e/clientdemo/ic_launcher-web.png
--------------------------------------------------------------------------------
/clientdemo/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_STL := stlport_static
2 | #APP_STL := gnustl_static
3 |
4 | #APP_STL := stl
5 |
6 | APP_PLATFORM := android-7
7 | #LOCAL_C_INCLUDES := ${ANDROID_NDK_ROOT}/sources/cxx-stl/stlport/stlport
8 |
9 | #TARGET_CPU_API := armeabi armeabi-v7a x86
10 | #APP_ABI := armeabi armeabi-v7a x86
11 |
12 | TARGET_CPU_API := armeabi
13 | APP_ABI :=
14 |
15 | APP_OPTIM := debug
16 | #APP_OPTIM := release
17 |
18 | #TARGET_CPU_API := armeabi arm64-v8a x86 x86_64 mips64
19 | #APP_ABI := armeabi-v7a
20 |
--------------------------------------------------------------------------------
/clientdemo/jni/android/client_jni.cpp:
--------------------------------------------------------------------------------
1 | #include "client_jni.h"
2 | #include "androidclient.h"
3 |
4 | #define C_STR(x) (gim::JstringToString(env, x).c_str())
5 |
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 | static gim::AndroidClient s_cli;
10 | JNIEXPORT jint JNICALL Java_com_gim_client_init(JNIEnv *env, jobject jcli, jobject jlstn)
11 | {
12 | if(s_cli.initJniEnv(env, jlstn) < 0)
13 | return -1;
14 |
15 | return s_cli.init();
16 | }
17 | JNIEXPORT jint JNICALL Java_com_gim_client_stop(JNIEnv *, jobject)
18 | {
19 | return s_cli.stop();
20 | }
21 | JNIEXPORT jint JNICALL Java_com_gim_client_login(JNIEnv* env, jobject job, jstring jsrvip, jint srvport,
22 | jstring jcliver, jint enc,jstring jcid, jstring jpwd)
23 | {
24 | return s_cli.login(C_STR(jsrvip), srvport, C_STR(jcid), C_STR(jpwd), enc, C_STR(jcliver));
25 | }
26 | JNIEXPORT jint JNICALL Java_com_gim_client_disconnect(JNIEnv *env, jobject job, jstring jcid)
27 | {
28 | return s_cli.disconnect(C_STR(jcid));
29 | }
30 | JNIEXPORT jint JNICALL Java_com_gim_client_sendPeerMessage(JNIEnv *env, jobject, jstring jcid, jstring sn, jstring peercid, jstring data)
31 | {
32 | return s_cli.sendPeerMessage(C_STR(jcid), C_STR(sn), C_STR(peercid), C_STR(data));
33 | }
34 |
35 | #ifdef __cplusplus
36 | }
37 | #endif
38 |
--------------------------------------------------------------------------------
/clientdemo/jni/android/client_jni.h:
--------------------------------------------------------------------------------
1 | #include
2 | #ifndef _CLIENT_JNI_H_
3 | #define _CLIENT_JNI_H_
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | JNIEXPORT jint JNICALL Java_com_gim_client_init
9 | (JNIEnv *, jobject, jobject);
10 |
11 | JNIEXPORT jint JNICALL Java_com_gim_client_stop
12 | (JNIEnv *, jobject);
13 |
14 | JNIEXPORT jint JNICALL Java_com_gim_client_login
15 | (JNIEnv* env, jobject job, jstring jsrvip, jint srvport, jstring jcliver, jint enc, jstring jcid, jstring jpwd);
16 |
17 | JNIEXPORT jint JNICALL Java_com_gim_client_disconnect
18 | (JNIEnv *, jobject, jstring);
19 |
20 | JNIEXPORT jint JNICALL Java_com_gim_client_sendPeerMessage
21 | (JNIEnv *env, jobject, jstring jcid, jstring sn, jstring peercid, jstring data);
22 |
23 | #ifdef __cplusplus
24 | }
25 | #endif
26 | #endif
27 |
--------------------------------------------------------------------------------
/clientdemo/jni/client_sdk/client.cpp:
--------------------------------------------------------------------------------
1 | #include "client.h"
2 | #include "ops.h"
3 | #include "common/ef_utility.h"
4 | namespace gim
5 | {
6 | std::string Client::getSN()
7 | {
8 | return itostr(m_sn++);
9 | }
10 | int32 Client::init()
11 | {
12 | m_sn = gettime_ms();
13 | m_evlp.setMsgCb(eventLoopMsgRoutine, (void*)this);
14 | m_evlp.startLoop();
15 | return 0;
16 | }
17 |
18 | int32 Client::login(const std::string& srvip, int32 srvport, const std::string& cid, const std::string& pwd, int32 enc, const std::string& version)
19 | {
20 | LoginOp* op = new LoginOp(cid);
21 | op->init(srvip, srvport, version, enc, pwd);
22 | return m_evlp.asynAddOp((Op*)op);
23 | }
24 | int32 Client::stop()
25 | {
26 | m_evlp.asynStop();
27 | return 0;
28 | }
29 | int32 Client::disconnect(const std::string& cid)
30 | {
31 | DisconnectOp* op = new DisconnectOp(cid);
32 | return m_evlp.asynAddOp((Op*)op);
33 | }
34 | int32 Client::sendPeerMessage(const std::string& cid, const std::string& sn, const std::string& peercid, const std::string& data)
35 | {
36 | SendPeerMessageOp* op = new SendPeerMessageOp(sn, cid);
37 | op->init(peercid, data);
38 | return m_evlp.asynAddOp((Op*)op);
39 | }
40 | int Client::eventLoopMsgRoutine(void* cli, const std::string& msg)
41 | {
42 | return cli ? ((Client*)cli)->handleMessage(msg) : -1;
43 | }
44 | int Client::handleMessage(const std::string& msg)
45 | {
46 | return 0;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/clientdemo/jni/client_sdk/client.h:
--------------------------------------------------------------------------------
1 | #ifndef _CLIENT_H_
2 | #define _CLIENT_H_
3 |
4 | #include "eventloop.h"
5 |
6 | namespace gim
7 | {
8 | class Client
9 | {
10 | public:
11 | Client(){};
12 | ~Client(){};
13 |
14 | std::string getSN();
15 |
16 | int32 init();
17 | int32 login(const std::string& srvip, int32 srvport, const std::string& cid, const std::string& pwd, int32 enc, const std::string& version);
18 | int32 stop();
19 | int32 disconnect(const std::string& cid);
20 | int32 sendPeerMessage(const std::string& cid, const std::string& sn, const std::string& peercid, const std::string& data);
21 | virtual int handleMessage(const std::string& msg);
22 | private:
23 | static int eventLoopMsgRoutine(void* cli, const std::string& msg);
24 | EventLoop m_evlp;
25 | int64 m_sn;
26 | };
27 | }
28 |
29 | #endif //_CLIENT_H_
30 |
--------------------------------------------------------------------------------
/clientdemo/jni/client_sdk/client_def.h:
--------------------------------------------------------------------------------
1 | #ifndef CLIENT_DEF_H
2 | #define CLIENT_DEF_H
3 |
4 | namespace gim
5 | {
6 | typedef enum _LoginStatus
7 | {
8 | STATUS_DO_LOGIN = 1,
9 | STATUS_LOGIN = 2,
10 | STATUS_LOGIN_FAIL = 3,
11 | STATUS_DISCONNECT = 4
12 | }LoginStatus;
13 |
14 | typedef enum _GResult
15 | {
16 | MY_OK = 0,
17 | MY_ERROR = -1,
18 | MY_NETWORK_ERROR = -9999,
19 | MY_PROBUF_FORMAT_ERROR = -9998,
20 | MY_TOO_LONG_PACKET = -9997,
21 | MY_JNI_ERROR = -9996,
22 | MY_JSON_ERROR = -9995,
23 | MY_UNDEFINED_CMD = -9994,
24 | MY_NOT_LOGGED = -9993,
25 | MY_TIMEOUT = -9992
26 | }GResult;
27 |
28 | typedef enum _NotifyType
29 | {
30 | NOTIFY_TYPE_LOGIN_STATUS_CHANGE = 0,
31 | NOTIFY_TYPE_PEER_MSG = 200,
32 | NOTIFY_TYPE_PEER_SEND_RESP = 201,
33 | NOTIFY_TYPE_PEER_OFFLINE_MSG = 202
34 | }NotifyType;
35 |
36 | };
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/clientdemo/jni/client_sdk/client_log.h:
--------------------------------------------------------------------------------
1 | #ifndef _CLIENT_SDK_LOG_H_
2 | #define _CLIENT_SDK_LOG_H_
3 |
4 | #include
5 | #include "client_def.h"
6 | #include
7 | #include
8 |
9 | namespace gim
10 | {
11 | typedef enum _LogLevel
12 | {
13 | LOG_LEVEL_TRACE = 1,
14 | LOG_LEVEL_WARN,
15 | LOG_LEVEL_DEBUG,
16 | LOG_LEVEL_ERROR
17 | }LogLevel;
18 |
19 | void logprint(LogLevel level, const char* logbuf);
20 |
21 | #ifdef _DEBUG
22 | #define SDK_LOG(lvl, format, ...)\
23 | {\
24 | char buf[1024];\
25 | snprintf(buf, sizeof(buf), "[lvl:%d] " format" [src=%s:%d]\n", (int32)lvl, ##__VA_ARGS__, __FILE__, __LINE__ );\
26 | logprint(lvl, buf); \
27 | }
28 | #else
29 | #define SDK_LOG(lvl, format, ...)\
30 | {\
31 | if(lvl >= LOG_LEVEL_ERROR)\
32 | {\
33 | char buf[1024];\
34 | snprintf(buf, sizeof(buf), "[lvl:%d] " format" [src=%s:%d]\n", (int32)lvl, ##__VA_ARGS__, __FILE__, __LINE__ );\
35 | logprint(lvl, buf); \
36 | }\
37 | }
38 | #endif
39 |
40 | }
41 |
42 |
43 | #endif
44 |
45 |
--------------------------------------------------------------------------------
/clientdemo/jni/client_sdk/err_no.h:
--------------------------------------------------------------------------------
1 | #ifndef ERR_NO_H
2 | #define ERR_NO_H
3 |
4 | namespace gim
5 | {
6 | enum
7 | {
8 | STATUS_OK = 0,
9 | INPUT_FORMAT_ERROR = -1,
10 | CHECK_TIME_FAIL = -2,
11 | CREATE_SESSION_FAIL = -10,
12 | GET_USER_KEY_FAIL = -11,
13 | DECRYPT_FAIL = -12,
14 | MISS_TOKEN = -13,
15 | CHECK_TOKEN_FAIL = -14,
16 | INVLID_SESSION_ID = -20,
17 | SESSION_TIMEOUT = -21,
18 | NO_SERVICE = -30,
19 | THIS_SERVICE_EMPTY = -31,
20 | SERVICE_EVENTLOOP_NULL = -32,
21 | SERVICE_TOO_BUSY = -33,
22 | INVALID_SN = -40,
23 | SN_TIMEOUT = -41,
24 | INNER_ERROR = -100,
25 |
26 | CONNECT_SERVER_FAIL = -600000,
27 | SEND_FAIL = -600010,
28 | REQUEST_TIME_OUT = -600020
29 | };
30 |
31 | inline const char* getErrStr(int32 e){
32 | switch (e){
33 | case STATUS_OK:
34 | return "STATUS_OK";
35 | case INPUT_FORMAT_ERROR:
36 | return "INPUT_FORMAT_ERROR";
37 | case GET_USER_KEY_FAIL:
38 | return "GET_USER_KEY_FAIL";
39 | case DECRYPT_FAIL:
40 | return "DECRYPT_FAIL";
41 | case MISS_TOKEN:
42 | return "MISS_TOKEN";
43 | case CHECK_TOKEN_FAIL:
44 | return "CHECK_TOKEN_FAIL";
45 | case CREATE_SESSION_FAIL:
46 | return "CREATE_SESSION_FAIL";
47 | case INVLID_SESSION_ID:
48 | return "INVLID_SESSION_ID";
49 | case NO_SERVICE:
50 | return "NO_SERVICE";
51 | case THIS_SERVICE_EMPTY:
52 | return "THIS_SERVICE_EMPTY";
53 | case SERVICE_EVENTLOOP_NULL:
54 | return "SERVICE_EVENTLOOP_NULL";
55 | case SESSION_TIMEOUT:
56 | return "SESSION_TIMEOUT";
57 | case SERVICE_TOO_BUSY:
58 | return "SERVICE_TOO_BUSY";
59 | case INVALID_SN:
60 | return "INVALID_SN";
61 | case SN_TIMEOUT:
62 | return "SN_TIMEOUT";
63 | case INNER_ERROR:
64 | return "INNER_ERROR";
65 | case REQUEST_TIME_OUT:
66 | return "REQUEST_TIME_OUT";
67 | case SEND_FAIL:
68 | return "SEND_FAIL";
69 | }
70 | return "";
71 | }
72 |
73 | };
74 |
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/clientdemo/jni/client_sdk/eventloop.h:
--------------------------------------------------------------------------------
1 | #ifndef _EVENT_LOOP_H_
2 | #define _EVENT_LOOP_H_
3 | #include "common/ef_sock.h"
4 | #include "common/ef_thread.h"
5 | #include "common/ef_loop_buf.h"
6 | #include "opbase.h"
7 | #include
8 | #include