Place Protubuf in the external folder
A new filter Protubuf is added to the luacocos2d in the VS project to add PB.C to the filter.
Compile the Pb.c file's properties into a C file.
Place the luastruct under the external LUA
A new filter Luastruc is added to the luacocos2d in the VS project to add struct.c to the filter.
Compile the Struct.c file's properties into a C file.
Then register in the Lua_module_rigister.cpp. Add the following code
#ifdef __cplusplus
extern "C" {
#endif
int Luaopen_protobuf_c (lua_state *l);
Intluaopen_struct (lua_state* L);
#ifdef __cplusplus
}
#endif
Add in the Lua_module_register function
Luaopen_protobuf_c (L);
Luaopen_struct (L);
At this point Protubuf can be run on Windows. But not on Android.
Modify the Android.mk file under Frameworks\cocos2d-x\cocos\scripting\lua-bindings\proj.android
#network
Local_src_files + =. /.. /.. /.. /external/protobuf/pb.c
#luastruct
Local_src_files + =. /.. /.. /.. /external/lua/luastruct/struct.c
This andriod can also be run.
For use in Lua, you still need to
Lua code to add protubuf under the LUA Engineering directory.
This protubuf can be used in Lua.
But if applied to the actual combat, still need to use Luasocket or WebSocket first read the packet, and then use Protubuf parse out the actual data.
Application installation of PROTUBUF in COCOS2DX