Last active
October 25, 2017 11:38
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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