Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A snippet for using an creating an Agora RTM message using JSON
function sendChannelMessage(property, direction){
if (localStreams.rtmActive) {
// use a JSON object to send our instructions in a structured way
const jsonMsg = {
property: property,
direction: direction
};
// build the Agora RTM Message
const msg = {
description: undefined,
messageType: 'TEXT',
rawMessage: undefined,
text: JSON.stringify(jsonMsg)
};
rtmChannel.sendMessage(msg).then(() => {
// channel message-send success
console.log('sent msg success');
}).catch(error => {
// channel message-send failure
console.log('sent msg failure');
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.