I'm using the chat api from your neon theme and is trying to figure out 2 things:
1. How do I handle when someone posts a message to a user in the chat window. I need to trap this event in Javascript so I can send it to the server for sending the message to the user on the other side. How do I do that? For example, I have User A logged in one one computer and User B on another. If user A types a message to user B on his chat window, I want to trap that event and the message so I can send that message to User B browser via my server.
2. Also, I want to remove the user when he goes offline. I receive the message from the server that the userid is offline but I don't see any API function on how to remove a user from the list. I see only move but not remove. I need to remove the user from the list. Is it possible?
I'm doing all of this in HTML / Javascript / JQuery. Please let me know if the above is possible and if so, how.
Sorry for delay of response as I wasn't in the office and other team members couldn't help with Neon API.
1. Regarding this question, I have implemented the Chat API functions in case when user has its own or wants to adapt any existing Chat platform using web sockets, for example you can use:
And implement the Chat API in Neon. It might not be full with options but you can implement anything you need.
2. As for this, I have realized that I forgot to create such a method, so you can add your own, here is an example how to achieve that:
...
removeUser: function( user_id ) {
if ( this.chat_history.hasOwnProperty( user_id ) ) {
var user = this.chat_history[ user_id ];
// remove dom element
user.$el.remove();
// delete user from chat history
delete this.chat_history[ user_id ];
// refresh/render
this.refreshUserIds();
this.orderGroups();
}
}
I'm using the chat api from your neon theme and is trying to figure out 2 things:
1. How do I handle when someone posts a message to a user in the chat window. I need to trap this event in Javascript so I can send it to the server for sending the message to the user on the other side. How do I do that? For example, I have User A logged in one one computer and User B on another. If user A types a message to user B on his chat window, I want to trap that event and the message so I can send that message to User B browser via my server.
2. Also, I want to remove the user when he goes offline. I receive the message from the server that the userid is offline but I don't see any API function on how to remove a user from the list. I see only move but not remove. I need to remove the user from the list. Is it possible?
I'm doing all of this in HTML / Javascript / JQuery. Please let me know if the above is possible and if so, how.
Thanks
Vinoth
Hi Vinoth,
Sorry for delay of response as I wasn't in the office and other team members couldn't help with Neon API.
1. Regarding this question, I have implemented the Chat API functions in case when user has its own or wants to adapt any existing Chat platform using web sockets, for example you can use:
https://socket.io/get-started/chat/
And implement the Chat API in Neon. It might not be full with options but you can implement anything you need.
2. As for this, I have realized that I forgot to create such a method, so you can add your own, here is an example how to achieve that:
I hope this helps you.