sacOO7 / socketcluster-android-demo

Sample chat app demo built using socketcluster framework in node.js
MIT License
12 stars 2 forks source link

Emitter listner is not working #1

Open venkykowshik opened 7 years ago

venkykowshik commented 7 years ago

i tried your demo and i was able send messages to other client but i was not able to recieve the messages from client what might be the reason is there any issue with code.

Note: I was using emaultor and testing with website

sacOO7 commented 7 years ago

Try to use two different android phones instead.It should work.

venkykowshik commented 7 years ago

Thank you for your reply.But also I tried with android Phone but still it is not working.

sacOO7 commented 7 years ago

Hey try to use library version 1.7.1. Can you just list down emitter and listener code down here?

venkykowshik commented 7 years ago

Yes i am using the 1.7.1 library only

see this below if could help me

    socket.on("MODPR14", new Emitter.Listener() {
        @Override
        public void call(String name, Object data) {
            Log.v("Recieved Msg","Got message for channel "+name+" data is "+data);
        }
    });
    Socket.Channel channel=socket.getChannelByName("MODPR14");
    channel.onMessage(new Emitter.Listener() {
        public void call(String channelName , Object object) {
            Log.v("Recieved Msg","Got message for channel "+channelName+" data is "+object);
        }
    });

    socket.onSubscribe("MODPR14",new Emitter.Listener() {
        @Override
        public void call(String name, final Object data) {
                Log.v("Recieved Msg","Got message for channel "+name+" data is "+data);
        }
    });
sacOO7 commented 7 years ago

There is no emitter code in above snippet. When using channels, you have to create one and then subscribe to it. Then only you can use channel.onMessage(). Just read the docs carefully. Give me the link to your repo. if possible.

sacOO7 commented 7 years ago

Also give me the current version of socketcluster :)

venkykowshik commented 7 years ago

1.7.1 i am using it and let me send you whole snippet of code by Git

venkykowshik commented 7 years ago

https://gist.github.com/venkykowshik/ca7d7c1fedc0c20b3f39aafa8e7f2f20

venkykowshik commented 7 years ago

hey Dude did you check the code did do anything wrong in that

sacOO7 commented 7 years ago

Hey I'm currently busy due to lot of work, I will be back after work is finished. Will solve the problem for sure :+1:

sacOO7 commented 7 years ago

Hey in your private void registerForMessages() method remove first two unnecessary callbacks, just keep

socket.onSubscribe("MODPR14",new Emitter.Listener() {
            @Override
            public void call(String name, final Object data) {

                    Log.v("Recieved Msg","Got message for channel "+name+" data is "+data);

            }
        });
sacOO7 commented 7 years ago

Try to keep private void registerForMessages() outside runnable

venkykowshik commented 7 years ago

I tried with that all options still not able to fix that can you help with that

sacOO7 commented 7 years ago

Upload your code on github repo., I will try to debug it

venkykowshik commented 7 years ago

sure i will do that send a link to you

venkykowshik commented 7 years ago

https://github.com/venkykowshik/socketcluster

venkykowshik commented 7 years ago

Hey Dude did u get a chance to look at my code....

venkykowshik commented 7 years ago

Please look into that code when you get a chance dude Thanks in Advance

sacOO7 commented 7 years ago

Hey actually I'm a lot busy those days, will it be ok if I ping you after 2-3 days :)

venkykowshik commented 7 years ago

Ok Dude thanks for the info will be waiting for reply

venkykowshik commented 7 years ago

Any update on this