-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsender.js
29 lines (26 loc) · 952 Bytes
/
sender.js
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
//load config file
var config = require("./config.js");
var pubnub = require("pubnub").init({
publish_key : PUBNUB.publish_key,
subscribe_key : PUBNUB.subscribe_key
});
/* ---------------------------------------------------------------------------
Publish Messages
--------------------------------------------------------------------------- */
var message = { "some" : "data" };
pubnub.publish({
channel : PUBNUB.channel_01,
message : message,
callback : function(e) { console.log( "SUCCESS!", e ); },
error : function(e) { console.log( "FAILED! RETRY PUBLISH!", e ); }
});
/* ---------------------------------------------------------------------------
Type Console Message
--------------------------------------------------------------------------- */
var stdin = process.openStdin();
stdin.on( 'data', function(chunk) {
pubnub.publish({
channel : "my_channel",
message : ''+chunk
});
});