var socket = io("wss://socket.agilepusher.com:3000", {
'reconnection': true,
'reconnectionDelay': 50000,
'reconnectionDelayMax' : 50000,
'reconnectionAttempts': 3,
'query': { apiKey:'API_KEY' },
transports: ['websocket']
});
Connection with Server is very simple. To establish connection we need to add the socket.io client script and just call a single IO function.
socket.emit('agRoomJoined', 'RoomName', 'SenderName', 'ReceiverName');
Subscribing a channel or joining a room is very simple. We need to call emit function of socket with four parameters, first parameter is the event name "agRoomJoined" and second is the channel/room name to join, third is the sender and last one is receiver.
socket.emit('agSendMessage', 'RoomName', 'Message here', 'UserName');
Send Messages to users.
socket.emit('agInfoMessage', 'Message here);
Sending Info message is very simple. To send info message we need to call emit function on socket.
socket.emit('agTyping', 'RoomName','Message here','Chat ID');
Informing the other users about the typing start status is a simple task we need only to call the emit function on socket object with four parameters, first parameter is the event name, the second parameter is the message, third room name, and fourth parameter is chat id.
socket.emit('agStopTyping', 'RoomName' ,'Chat ID');
Informing users about typing's stop status is also very simple. We need to call emit function on socket with two parameters, first parameter is the 'agStopTyping' as event name and the second one is the chat id.
socket.emit('agMessageSeen', 'RoomName','Message Here','Chat ID');
Informing users about message seen status is a simple task. We need to call a emit function on socket object with four parameters, first is the "agMessageSeen" event name, second parameter is the room name, third parameter is the message, and the fourth parameter is chat id.