forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.js
More file actions
34 lines (28 loc) · 1.03 KB
/
Copy pathhello.js
File metadata and controls
34 lines (28 loc) · 1.03 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
/* ---------------------------------------------------------------------------
Init PubNub and Get your PubNub API Keys:
http://www.pubnub.com/account#api-keys
--------------------------------------------------------------------------- */
console.log('Type your message, press ENTER.\n');
var pubnub = require("./../pubnub.js").init({
publish_key : "demo",
subscribe_key : "demo"
});
/* ---------------------------------------------------------------------------
Listen for Messages
--------------------------------------------------------------------------- */
pubnub.subscribe({
channel : "my_channel",
callback : function(message) {
console.log( " > ", message );
}
});
/* ---------------------------------------------------------------------------
Type Console Message
--------------------------------------------------------------------------- */
var stdin = process.openStdin();
stdin.on( 'data', function(chunk) {
pubnub.publish({
channel : "my_channel",
message : ''+chunk
});
});