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
pubnub.subscribe({channels: [channel]}); | |
pubnub.addListener({ | |
presence: function(m){ | |
document.getElementById('occupancy').textContent = m.occupancy; | |
} | |
}); |
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
pubnub.publish({ | |
channel : 'mouseMoves', | |
message : { | |
x: 400, | |
y: 200 | |
} | |
}); |
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
Enter Chat and press enter | |
<div><input id=input placeholder=you-chat-here /></div> | |
Chat Output | |
<div id=box></div> | |
<script src=https://cdn.pubnub.com/sdk/javascript/pubnub.4.0.11.min.js></script> | |
<script>(function(){ | |
var pubnub = new PubNub({ publishKey : 'demo', subscribeKey : 'demo' }); | |
function $(id) { return document.getElementById(id); } |