Example of usage Socket at Cocos2dx
I create an online multiplayer game, but with network programming I have bad, long searching around the internet ready code to use socket on the mobile device tried many different solutions, until I met a good man named Odison ( I hope that's your real name :) ) he sent me to a good example of a ready source code, and it is now here, I have added the implementation of the server and you can use it as you wish.
- download and install Java JDK >= 1.7 http://www.oracle.com/technetwork/java/javase/downloads/index.html
- download and install Maven https://maven.apache.org/
- download and install Gradle http://gradle.org/
- clone Cocos2dx https://github.com/cocos2d/cocos2d-x
- create liked directory of Cocos2dx to '/opt/cocos2dx'
- clone Protobuf https://github.com/google/protobuf
- (optional) build Protobuf protoc compiler
- copy build-protobuf-iphonesim.sh into Protobuf directory and run it, this file builds static library of Protobuf, in my case it is plased to '/usr/local/lib/platform/x86_64-sim/lib/'
- create linked directory of Protobuf into '/opt/protobuf'
- build Protobuf for Java (it is because at socket server we use Java) goto protobuf/java and run 'mvn install -P lite -Dmaven.test.skip' then 'mvn install:install-file -Dfile=./target/protobuf-java-3.0.0-alpha-4-pre.jar -Dclassifier=lite'
- goto server and run 'gradle installApp' this builds socket server
- run socket server from 'server/build/install/socket_server/bin/socket_server'
- run socket client from 'client/proj.ios_mac/SocketClient.xcodeproj'
Currently i setup client only for Apple iOS, send me pull request for Android.