The simple instant messaging application below illustrates the use of the Respoke messaging API's. In this instance, Bob and Alice (two users) can send and receive messages to one another. Normally, each user would only see their individual chat window, but for the sake of the example we display both users below.
Sending messages between endpoints requires that you first establish a connection from each endpoint to Respoke using the connect method of the Client object. Once the connection is established, sending a message to another endpoint is a simple matter of calling the sendMessage method of the Client object and passing in an object containing the endpoint ID of the recipient, and the message you wish to send. In order to receive incoming messages from other users, you will also need to add a listener for the message event on your Client object.