Skip to content

Commit

Permalink
[GS] fixes possible exception when client disconnects - ci release
Browse files Browse the repository at this point in the history
  • Loading branch information
lesquoyb committed Aug 4, 2023
1 parent fa1baf5 commit 30ab9f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Expand Up @@ -159,8 +159,7 @@ public void onOpen(final WebSocket conn, final ClientHandshake handshake) {
// conn.getRemoteSocketAddress().getAddress().getHostAddress() + " to the
// server!");
// broadcast("new connection: " + handshake.getResourceDescriptor()); // This
// method sends a message to all clients connected
DEBUG.OUT(conn.getRemoteSocketAddress().getAddress().getHostAddress() + " entered the room!");
// method sends a message to all clients connected DEBUG.OUT(conn.getRemoteSocketAddress().getAddress().getHostAddress() + " entered the room!");
conn.send(Jsoner
.serialize(new GamaServerMessage(GamaServerMessageType.ConnectionSuccessful, "" + conn.hashCode())));

Expand All @@ -169,7 +168,9 @@ public void onOpen(final WebSocket conn, final ClientHandshake handshake) {
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
conn.sendPing();
if (conn.isOpen()) {
conn.sendPing();
}
}
}, 0, pingInterval);
pingTimers.put(conn, timer);
Expand Down
Expand Up @@ -22,7 +22,7 @@ public CommandResponse execute(final WebSocket socket, final IMap<String, Object
}

try (FileWriter myWriter = new FileWriter(filepath)) {
myWriter.write("" + content);
myWriter.write(content);
return new CommandResponse(GamaServerMessageType.CommandExecutedSuccessfully, "", map, false);
} catch (Exception ex) {
ex.printStackTrace();
Expand Down

0 comments on commit 30ab9f1

Please sign in to comment.