-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
31 lines (25 loc) · 759 Bytes
/
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
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static(path.join(__dirname, 'public')));
var ms = require('./microsocket-server')(app);
ms.on("test", function (data) {
console.log("On test");
});
var sockets = [];
ms.on('connection',function(socket){
sockets.push(socket);
socket.on("message",function (data) {
sockets.forEach(function (skt) {
console.log("emitting " + "message-"+data);
skt.emit("message","message-"+data);
});
});
});
//setInterval(function () {
// ms.emit("poll", {});
//}, 1000);
module.exports = app;