Commit 0d432118 authored by mercury233's avatar mercury233

fix

parent 2f69b16d
...@@ -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));
} }
} }
......
...@@ -1535,6 +1535,7 @@ if settings.modules.spawn_windbot ...@@ -1535,6 +1535,7 @@ if settings.modules.spawn_windbot
windbot_process.stdout.on 'data', (data)-> windbot_process.stdout.on 'data', (data)->
log.info 'WindBot:', data log.info 'WindBot:', data
return return
windbot_process.stderr.setEncoding('utf8')
windbot_process.stderr.on 'data', (data)-> windbot_process.stderr.on 'data', (data)->
log.warn 'WindBot Error:', data log.warn 'WindBot Error:', data
return return
...@@ -1638,5 +1639,5 @@ if settings.modules.http ...@@ -1638,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
...@@ -1931,6 +1931,7 @@ ...@@ -1931,6 +1931,7 @@
windbot_process.stdout.on('data', function(data) { windbot_process.stdout.on('data', function(data) {
log.info('WindBot:', data); log.info('WindBot:', data);
}); });
windbot_process.stderr.setEncoding('utf8');
windbot_process.stderr.on('data', function(data) { windbot_process.stderr.on('data', function(data) {
log.warn('WindBot Error:', data); log.warn('WindBot Error:', data);
}); });
...@@ -2054,7 +2055,7 @@ ...@@ -2054,7 +2055,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