Cannot receive chat messages

0 votes

When I join a static room with 2 clients (A, B) and A succesfully sends a chat message the onChatReceived listener is not called on B. The chat is sent since the A's onSendChatDone result is 0. What could be the problem here?

Update: Joining and subscribing to the room did not fix the issue.

client.joinRoom(6326129);

client.setResponseListener(AppWarp.Events.onJoinRoomDone, function (response) {
        var resultCode = response.getResult();
 
        if (resultCode === ResultCodes.SUCCESS) {
            console.info('Joined room', response.getName());
            client.subscribeRoom(response.getRoomId());
        } else {
            throw new Error('Could not join room.');
        }
    });
 
client.setResponseListener(AppWarp.Events.onSubscribeRoomDone, function (response) {
        var resultCode = response.getResult();
 
        if (resultCode === ResultCodes.SUCCESS) {
            console.info('Subscribed to room', response.getName());
        } else {
            throw new Error('Could not subscribe to room ' + response.getName());
        }
    });
 

Output in console on all clients:

Joined room ABCD
Subscribed to room ABCD
 
Still clients do not receive the message.
 
client.setResponseListener(AppWarp.Events.onChatReceived, function (response) {
        console.info(response.getChat());
    });

 

asked Feb 3, 2015 in AppWarp by bart.tegenbosch (10 points)
edited Feb 5, 2015 by bart.tegenbosch

2 Answers

0 votes
HI,

You will also need to subscribe to a room. One you join a room you become a part of it. But to receive notifications you also need to subscribe to it. You can also subscirbe a room without joining it. But then you will only receive notifications and will not be able to send messages too.

Thanks
answered Feb 4, 2015 by Suyash Mohan (900 points)
I'm sorry. I omitted that detail since I thought I read somewhere that joining a room would subscribe me automatically. Guess I read it wrong. I did join + subscribe in a earlier test which didn't work as well.
Can you please try again. After subscribing a room, player should get notifications
I updated my question. Could you have another look?
What is the return value onSendChatDone? When you send a chat the sender also receives onSendChatDone callback. onSendChatDone will let you know if your sendChat() method was successful or not.
The resultcode is 0. So it is sent.
@SuyashMohan Any ideas?
Can you try running any of our sample? If the sample works correctly you can compare your code with Sample Code and see what you have missed
Was this ever resolved?  I'm having the same issue.  I can receive private messages, but updates and regular messages are not received.  If I fix it before you reply, I'll let you know.

On a side note, I opened the port 12346 on my router and also disabled my firewall.

The provided sample doesn't receive messages either.

I'll keep you updated.
0 votes

I had the same problem and it turns out it was from not subscribing to the room, not disabling my firewall, and not opening the port "12346" on the router.  

Also, if you want to test out receiving messages without having to build two versions of your project, just remove whatever code filters the current user when implementing received messages.  For instance, anything that looks like this:

if(eventObj.getSender() != appwarp.username)
{
	appwarp.movePlayer(msg["x"].AsFloat,msg["y"].AsFloat,msg["z"].AsFloat);

        Debug.Log(msg["x"].ToString() + " " + msg["y"].ToString() + " " + msg["z"].ToString());
}

Should just be changed to this temporarily:
 

if(eventObj.getSender() == appwarp.username)
{
	appwarp.movePlayer(msg["x"].AsFloat,msg["y"].AsFloat,msg["z"].AsFloat);

        Debug.Log(msg["x"].ToString() + " " + msg["y"].ToString() + " " + msg["z"].ToString());
}

 

answered Mar 25, 2016 by null (23 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...