Skip to content
This repository was archived by the owner on Mar 6, 2018. It is now read-only.
This repository was archived by the owner on Mar 6, 2018. It is now read-only.

Can't get emit respond #116

Open
Open

Description

@anormobile

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 is passing automatically, after success connect to the server.

    private void getList(SocketIO socket) {
        try {
            socket.emit(EventList.GETLIST, new JSONObject().put("sortByDate", true));
            Log.v("getList", "Emit was sent!!!<<<<<<<<<<<<<<<<<<");
        } catch (JSONException e) {
            e.printStackTrace();
            Log.v("getList", "Emit was !!!!!!!!!!!!NOT!!!!!!!!!!!!!!! sent!!!<<<<<<<<<<<<<<<<<<");
        }
    } 
    @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;
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﹕ Emit was sent!!!<<<<<<<<<<<<<<<<<<
I/io.socket﹕ > 2::
I/io.socket﹕ > 5:::{"name":"getlist","args":[{"sortByDate":true}]}
V/getList﹕ Emit was sent!!!<<<<<<<<<<<<<<<<<<
I/io.socket﹕ < 2::
I/io.socket﹕ > 2::

Activity

  1. anormobile commented on Feb 11, 2015

    @anormobile
    Author

    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:

    IOAcknowledge ack = new IOAcknowledge() {
    @Override
    public void ack(Object... args) {
        if (args.length > 0) {
            Log.d("SocketIO", "" + args[0]);
        }
    }
    }

    And pass the IOAcknowledge to the emit method:

    socket.emit(EventList.GETLIST, ack, new JSONObject().put("sortByDate", true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions