This is the server script. It sends “Hello” upon a new socket connected and has another listener “rpc”.
That “rpc” listener sends “rpc_ret” to client.
Here’s client script
Upon the client connects, it emits a “rpc” message with a data object.
Here’re the test results:
First tested on Browser and resulted as desire (logs from console):
The was from NodeJS. The request from browser was successfully logged.
And then, complied, sync the apk from adb and ran the app.
Here’re the logs from logcat:
There were warnings:
09-17 00:35:13.634: W/dalvikvm(17476): dvmFindClassByName rejecting 'org/cocos2dx/lib/Cocos2dxLocalStorage'
09-17 00:35:43.374: W/dalvikvm(17476): dvmFindClassByName rejecting 'org/cocos2dx/lib/Cocos2dxHttpURLConnection'
Not sure they were the causes. Nonetheless, from the log, I learnt that object can’t be sent as parameter. So, I modified my codes to send as string.
Client Script (before sending to server:)
Then, compiled and tested again
Emit was called without error now. But, server didn’t receive any call. I also noticed there were several onMessage calls in the Android log. So, I thought, server was sending the calls.
So, I modified server codes again to log before sending “hello”. Then I found out that server was not sending the “hello” calls. Other than replys to “rpc” calls with “rpc_ret”. So, I think, “rpc_ret” calls were being replaced by previous “hello” call. I think, they were mixed up somehow somewhere.
I don’t know how to continue as I ran out of ideas.
Perhaps, if you have working sample that you can share with, I’d be glad to have it and learn from it.
Thanks in advance again… T.T
Hope you can help me… @hannon235…
@lambda… @pandamicro… . Could you please help me too?