Commit cafb1b3b authored by mercury233's avatar mercury233

fix

parent 5d949d4b
...@@ -10,14 +10,14 @@ room_data = (room)-> ...@@ -10,14 +10,14 @@ room_data = (room)->
users: ({username: client.name, position: client.pos} for client in room.players), users: ({username: client.name, position: client.pos} for client in room.players),
options: room.hostinfo options: room.hostinfo
init = (http_server, Room)-> init = (http_server, ROOM_all)->
server = new WebSocketServer server = new WebSocketServer
server: http_server server: http_server
server.on 'connection', (connection) -> server.on 'connection', (connection) ->
connection.send JSON.stringify connection.send JSON.stringify
event: 'init' event: 'init'
data: room_data(room) for room in Room.all when room.established and !room.private and !room.started data: room_data(room) for room in ROOM_all when room and room.established and !room.private and !room.started
create = (room)-> create = (room)->
broadcast('create', room_data(room)) broadcast('create', room_data(room))
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
}; };
}; };
init = function(http_server, Room) { init = function(http_server, ROOM_all) {
server = new WebSocketServer({ server = new WebSocketServer({
server: http_server server: http_server
}); });
...@@ -40,12 +40,11 @@ ...@@ -40,12 +40,11 @@
return connection.send(JSON.stringify({ return connection.send(JSON.stringify({
event: 'init', event: 'init',
data: (function() { data: (function() {
var i, len, ref, results; var i, len, results;
ref = Room.all;
results = []; results = [];
for (i = 0, len = ref.length; i < len; i++) { for (i = 0, len = ROOM_all.length; i < len; i++) {
room = ref[i]; room = ROOM_all[i];
if (room.established && !room["private"] && !room.started) { if (room && room.established && !room["private"] && !room.started) {
results.push(room_data(room)); results.push(room_data(room));
} }
} }
......
...@@ -1639,5 +1639,5 @@ if settings.modules.http ...@@ -1639,5 +1639,5 @@ if settings.modules.http
cert: fs.readFileSync(settings.modules.http.ssl.cert) cert: fs.readFileSync(settings.modules.http.ssl.cert)
key: fs.readFileSync(settings.modules.http.ssl.key) key: fs.readFileSync(settings.modules.http.ssl.key)
https_server = https.createServer(options, requestListener) https_server = https.createServer(options, requestListener)
roomlist.init https_server, Room roomlist.init https_server, ROOM_all
https_server.listen settings.modules.http.ssl.port https_server.listen settings.modules.http.ssl.port
\ No newline at end of file
...@@ -2049,7 +2049,7 @@ ...@@ -2049,7 +2049,7 @@
key: fs.readFileSync(settings.modules.http.ssl.key) key: fs.readFileSync(settings.modules.http.ssl.key)
}; };
https_server = https.createServer(options, requestListener); https_server = https.createServer(options, requestListener);
roomlist.init(https_server, Room); roomlist.init(https_server, ROOM_all);
https_server.listen(settings.modules.http.ssl.port); https_server.listen(settings.modules.http.ssl.port);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment