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.
<img src="/uploads/default/10796/e5cb2510e19230e0.PNG" width=“690” height=“443”>
Here’s client script
<img src="/uploads/default/10797/7fd27fb69af22736.PNG" width=“690” height=“491”>
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):
<img src="/uploads/default/10798/fe8a4546459aa8df.PNG" width=“687” height=“110”>
The was from NodeJS. The request from browser was successfully logged.
<img src="/uploads/default/10799/46a6dcd514b2de6a.PNG" width=“569” height=“51”>
And then, complied, sync the apk from adb and ran the app.
Here’re the logs from logcat:
<img src="/uploads/default/10800/45e4cbbf95b85f04.PNG" width=“580” height=“500”>
<img src="/uploads/default/10801/dd581bde8566691d.PNG" width=“684” height=“257”>
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:)
<img src="/uploads/default/10802/c3abcb9ebd7b874c.PNG" width=“292” height=“48”>
Then, compiled and tested again
<img src="/uploads/default/10803/65f2919a1afdff27.PNG" width=“682” height=“447”>
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?