Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions wpilots.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@ function start_gameserver(maps, options, shared) {

if (connection.last_ping + 2000 < time) {
connection.last_ping = time;
connection.send(JSON.stringify([PING_PACKET]));
try {
connection.send(JSON.stringify([PING_PACKET]));
} catch (err) {
log(connection + ' send error (Reason: ' + err + ')');
return;
}
}
if (update_tick % connection.update_rate != 0) {
continue;
Expand Down Expand Up @@ -431,7 +436,12 @@ function start_gameserver(maps, options, shared) {
for(var id in connections) {
var conn = connections[id];
if (conn.state == JOINED) {
conn.send(JSON.stringify([OP_WORLD_RECONNECT]));
try {
conn.send(JSON.stringify([OP_WORLD_RECONNECT]));
} catch (err) {
log(conn + ' send error (Reason: ' + err + ')');
return;
}
conn.set_state(HANDSHAKING);
}
}
Expand Down Expand Up @@ -613,7 +623,12 @@ function start_gameserver(maps, options, shared) {
} else {
for(var id in connections) {
var conn = connections[id];
conn.send(JSON.stringify([OP_WORLD_RECONNECT]));
try{
conn.send(JSON.stringify([OP_WORLD_RECONNECT]));
} catch (err) {
log(conn + ' send error (Reason: ' + err + ')');
return;
}
conn.set_state(HANDSHAKING);
}
}
Expand Down Expand Up @@ -700,7 +715,13 @@ function start_gameserver(maps, options, shared) {
*/
conn.post = function(data) {
var packet = JSON.stringify(data);
this.send(packet);
try {
this.send(packet);
} catch (err){
log(this + ' send error (Reason: ' + err + ')');
return;
}

}

/**
Expand All @@ -722,6 +743,7 @@ function start_gameserver(maps, options, shared) {
this.send('[' + GAME_PACKET + ',[' + packet_data.join(',') + ']]');
this.data_sent += data_sent;
} catch (err) {
log(this + ' send error (Reason: ' + err + ')');
return;
}

Expand Down