var socket = io("wss://socket.agilepusher.com:3000", { 'reconnection': true, 'reconnectionDelay': 50000, 'reconnectionDelayMax' : 50000, 'reconnectionAttempts': 3, 'query': { apiKey:'API_KEY' }, transports: ['websocket'] });

Connect to the server

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');

Subscribe a Channel

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 Message

Send Messages to users.

socket.emit('agInfoMessage', 'Message here);

Send Info Message

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');

Typing Start

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');

Typing Stop

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');

Message Seen

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.

Congratulations! Your email has been verified.