1 | var connect = require('connect'),
|
2 | serveStatic = require('serve-static'),
|
3 | app = connect();
|
4 |
|
5 | app.use(serveStatic('public', {'index': 'index.html'})).listen(80);
|
6 |
|
7 | var roomdata = require('./roomdata'),
|
8 | io = require('socket.io').listen(8080);
|
9 |
|
10 | io.sockets.on('connection', function (socket) {
|
11 |
|
12 | roomdata.joinRoom(socket, "testroom");
|
13 |
|
14 |
|
15 | roomdata.set(socket, "gamedata", {x:4, y:20});
|
16 | roomdata.set(socket, "timesdied", 5);
|
17 |
|
18 |
|
19 | console.log(roomdata.get(socket, "gamedata"));
|
20 | console.log(roomdata.get(socket, "gamedata").y);
|
21 |
|
22 |
|
23 |
|
24 | var inc = roomdata.get(socket, "timesdied") + 10;
|
25 | roomdata.set(socket, "timesdied", inc);
|
26 | console.log(roomdata.get(socket, "timesdied"));
|
27 |
|
28 |
|
29 | console.log(roomdata.get(socket, "users"));
|
30 | console.log(roomdata.get(socket, "room"));
|
31 | console.log(roomdata.get(socket, "owner"));
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | socket.on('disconnect', function() {
|
37 | roomdata.leaveRoom(socket);
|
38 | });
|
39 | }); |
\ | No newline at end of file |