If somebody can show me, what's wrong with my code? I really spend a lot of time in attempt to figure out this issue. The "chatinfo" event, which you can see in the Log is passing automatically, after successful connection to the server.
I use: Gottox/socket.io-java-client on Android device, http://socket.io/ 0.9.16 on the server, authorization is by passing token in header on the connection establishing.
Code:
private void getList(SocketIO socket) {
try {
socket.emit(EventList.GETLIST, new JSONObject().put("sortByDate", true));
Log.v("getList", "emitted");
} catch (JSONException e) {
e.printStackTrace();
Log.v("getList", "not emitted");
}
}
Code:
@Override
public void on(String s, IOAcknowledge ioAcknowledge, Object... objects) {
JSONObject respond = (JSONObject) objects[0];
Log.d("testFromOn", "String s = " + s);
Log.d("testFromOn", "on" + respond);
switch (s) {
case GETLIST:
Log.d("GETLIST", "GETLIST responce: " + s);
break;
Log
I/io.socket﹕ < 1::
D/test﹕ onConnect
I/io.socket﹕ < 5:::{"name":"chatinfo","args":[{"onlineCount":0,"onlineFriendsCount":0,"unreadCount":7,"unreadFriendsCount":0,"userInfo":{"avatar":"1415903272343.jpg","url":"/user/5431b4955518085d5db4be23","_id":"5431b4955518085d5db4be23"}}]}
D/testFromOn﹕ String s = chatinfo
D/testFromOn﹕ on{"onlineCount":0,"onlineFriendsCount":0,"unreadCount":7,"unreadFriendsCount":0,"userInfo":{"avatar":"1415903272343.jpg","url":"\/user\/5431b4955518085d5db4be23","_id":"5431b4955518085d5db4be23"}}
I/io.socket﹕ > 5:::{"name":"getlist","args":[{"sortByDate":true}]}
V/getList﹕ emitted
I/io.socket﹕ > 2::
I/io.socket﹕ > 5:::{"name":"getlist","args":[{"sortByDate":true}]}
V/getList﹕ emitted
I/io.socket﹕ < 2::
I/io.socket﹕ > 2::
Finally my problem was not so really problem. I just miss to add one more parameter to my emit. So nobody catch the server's respond.
The only one thing was to add:
And pass the IOAcknowledge to the emit method: