forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (31 loc) · 1.22 KB
/
app.js
File metadata and controls
40 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(function(){
// -----------------------------------------------------------------------
// PUBNUB SETUP
// -----------------------------------------------------------------------
var pubnub_setup = {
channel : 'bootstrap-app',
password : '*HLSGHUSEHJFIlT#YUTGKJDHKJ',
publish_key : 'demo',
subscribe_key : 'demo'
};
// -----------------------------------------------------------------------
// CREATE CONNECTION FOR USER EVENTS
// -----------------------------------------------------------------------
var socket = io.connect( 'http://pubsub.pubnub.com/events', pubnub_setup );
// -----------------------------------------------------------------------
// WAIT FOR A CONNECTION
// -----------------------------------------------------------------------
socket.on( 'connect', function() {
// Connected!!!
socket.send('SUPER SECRET!!!!!!! EATING BATTERIES');
} );
// -----------------------------------------------------------------------
// RECEIVE A MESSAGE
// -----------------------------------------------------------------------
socket.on( 'message', function(message) {
// Received a Message!
console.log(message);
// i0cz1TAv8dWjsu6F
// HfhzNsTGrc66OZgEFL4jmjvXC1Zg6J
} );
})();