-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (33 loc) · 1.07 KB
/
app.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
30
31
32
33
34
35
36
37
38
39
40
var azure = require('azure');
var config = require('./config');
var WebSocket = require('ws');
var stdin = process.stdin;
var sbService = azure.createServiceBusService(config.sbConnectionString);
var ws = new WebSocket(config.sourceSocket);
ws.on('open', function() {
console.log('Connected to ' + config.sourceSocket);
});
ws.on('message', function(data, flags) {
var message = new Buffer(data).toString('base64');
console.log('Message received, length in b64: ' + message.length);
sbService.sendTopicMessage(config.sbTopic, message, function(error){
if(error) {
console.error(error);
} else {
console.log('Message written to ' + config.sbTopic);
}
});
});
/*
stdin.on('data', function(chunk) {
var message = new Buffer(chunk).toString('base64');
console.log('STDIN received, length in b64: ' + message.length);
sbService.sendTopicMessage(config.sbTopic, message, function(error){
if(error) {
console.error(error);
} else {
console.log('Message written to ' + config.sbTopic);
}
});
});
*/