Skip to content

Instantly share code, notes, and snippets.

@push-gists
Last active October 25, 2017 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save push-gists/8ed8c52ca067700fb48a3d11bdc8917e to your computer and use it in GitHub Desktop.
Save push-gists/8ed8c52ca067700fb48a3d11bdc8917e to your computer and use it in GitHub Desktop.
Appending a new chat message to the time series topic. Using a JSON event to represent messages allows us to add extra metadata about the sender.
var sendTextMessage = function(session){
var input = $("#chatinput").val();
$("#chatinput").val('');
if(session.isConnected() && (input.replace(/\s/g, '').length > 0)){
var message = {
origin: chatUserId,
type: 'txtmsg',
payload: input
};
session.timeseries.append(chatTopic, message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment