Skip to content

Commit

Permalink
add ping
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkars committed May 31, 2024
1 parent 8050dca commit e91884a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<revision>0.95.18</revision>
<revision>0.98.0</revision>
</properties>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ public void handleMessage(WebSocketSession session, WebSocketMessage<?> message)
case ERROR:
sendError(session, "cannot send errors to server!");
break;
case PING:
JsonObject pingMessage = new JsonObject();
pingMessage.addProperty("type", "ping");
pingMessage.addProperty("message", "pong");
pingMessage.addProperty("serverVersion", buildVersion);
session.sendMessage(new TextMessage(gson.toJson(pingMessage)));
break;
case GAME:
case GAME_UNDO:
case GAME_REDO:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ public enum MessageType {
@SerializedName("error")
ERROR,

@SerializedName("ping")
PING,

}

0 comments on commit e91884a

Please sign in to comment.