-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappv2.js
More file actions
34 lines (26 loc) · 828 Bytes
/
appv2.js
File metadata and controls
34 lines (26 loc) · 828 Bytes
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
var amqp = require('amqplib/callback_api');
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http, {
path: '/appv2/socket.io',
});
var channel;
var q = 'frs-messaging';
var port = 9000;
http.listen(port);
app.get('/appv2', function (req, res) {
res.sendFile(__dirname + '/appv2.html');
});
http.listen(port, function (err) {
console.log('Express app running on port:', port);
});
amqp.connect('amqp://localhost', function (err, conn) {
conn.createChannel(function (err, ch) {
channel = ch;
ch.assertQueue(q, { durable: false });
ch.consume(q, function (msg) {
console.log(' [x] Received \'', msg.content.toString(), '\' from ', msg.properties.appId);
io.emit('chat message', msg.content.toString());
}, { noAck: true });
});
});