forked from dongwenxiao/snakes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameServer.js
62 lines (36 loc) · 1.08 KB
/
gameServer.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require('babel-core/register');
var app = require('http').createServer(handler)
var io = require('socket.io')(app);
var fs = require('fs');
// var gameServerLogic = require('./src/game/serverLogic')
// require('./test')
app.listen(8080);
var serverCache = {
name: 'victor'
}
function handler (req, res) {
res.writeHead(200);
res.end('There \' nothing. ');
}
// id
// socket.id
// 连接数量
// io.sockets.server.engine.clientsCount
// 特定某个用户
// io.sockets.sockets[socket.id].emit('message', 'find you send')
// 当前请求用户
// socket.emit('message', "this is a emit");
// 除了当前用户的所有用户
// socket.broadcast.emit('message', "this is a broadcast");
// 全部用户
// io.sockets.emit('message', "this is a emit all");
var gameServerLogic = require('./src/game/serverLogic')(io)
io.on('connection', function (socket) {
gameServerLogic.init(socket)
// socket.on('my other event', function (data) {
// console.log(data);
// });
// socket.on('disconnect', function(msg){
// console.log(socket.id + ' leave')
// });
})