Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

Cannot create received message with socket.io #14

Open
gusreyes01 opened this issue Mar 17, 2015 · 0 comments
Open

Cannot create received message with socket.io #14

gusreyes01 opened this issue Mar 17, 2015 · 0 comments

Comments

@gusreyes01
Copy link

What I'm trying to achieve is to receive a message sent by a user in another window, however the response is printed multiple times.

Its seems to me like the 'DemoServerAdapter.prototype.sendMessage' function is called x times as messages already sent.

               socket.on('chat_receive', function(message) {
                console.log(message);
                var echoMessage = new ChatMessageInfo();
                echoMessage.UserFromId = message.send_user_id; // It will be from Echobot
                echoMessage.RoomId = roomId;
                echoMessage.ConversationId = conversationId;
                echoMessage.Message = "The other: " + message.message;

                // if it's not a private message, the echo message will be to the current user
                if (!roomId && !conversationId)
                    echoMessage.UserToId = current_user_id;  // Id del usuario actual

                // this will send a message to the user 1 (you) as if it was from user 2 (Echobot)
                _this.clientAdapter.triggerMessagesChanged(echoMessage);
                 });

Example:

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant