-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (28 loc) · 767 Bytes
/
server.js
File metadata and controls
34 lines (28 loc) · 767 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 express = require('express');
var app =express();
var http = require('http');
var httpServer = http.createServer(app);
var io = require('socket.io')(httpServer);
app.use(express.static(__dirname));
app.get('/', function(req, res){
res.sendFile(__dirname + '/app/index.html');
});
httpServer.listen(3000, function(){
console.log('listening on *:3000');
});
const numOfEntities = 500;
const interval =2;
io.on('connection', function (socket) {
let counter = 0;
setInterval(()=>{
socket.emit('birds',
{
id: counter++ % numOfEntities,
action: 'ADD_OR_UPDATE',
entity: {
name: 'bird',
image: "/assets/angry-bird-blue-icon.png"
}
})
}, interval);
});