sono.land
Payload
Payload
Sending data through the payload object
When a client invokes a method, data is sent as the value of the payload property in a packet. The payload is designed to be versatile so it may contain a message, a channel to change to, and more.
1/* In this example, it is assumed that a different client has sent a message.2The recipient below is listening for a message and has access to the payload of a packet.3The recipient will then be able to display the data from the payload.4*/5
6sono.on('message', (payload) => {7 const message = document.createElement('li');8 message.innerText = payload.message;9 messageBoard.appendChild(message);10});