debugs
All checks were successful
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 56s
All checks were successful
Deploy API / deploy (ubuntu-latest, 2.44.0) (push) Successful in 56s
This commit is contained in:
parent
cd4a57a4f2
commit
2f0b6d5982
@ -56,22 +56,30 @@ public class WebSocket extends TextWebSocketHandler {
|
|||||||
log.info("Active Sessions: {}", activeSessions.size());
|
log.info("Active Sessions: {}", activeSessions.size());
|
||||||
}
|
}
|
||||||
for (WebSocketClient client : activeSessions.values()) {
|
for (WebSocketClient client : activeSessions.values()) {
|
||||||
// Disconnect users that have not been active for 15 seconds
|
String sessionId = client.getSession().getId();
|
||||||
if (client.getListeningTo() == null && ((System.currentTimeMillis() - client.getConnected()) >= TimeUnit.SECONDS.toMillis(15L))) {
|
System.out.println("client.getSession().getId() = " + sessionId);
|
||||||
|
|
||||||
|
// Disconnect users that have not been active for 30 seconds
|
||||||
|
if (client.getListeningTo() == null && ((System.currentTimeMillis() - client.getConnected()) >= TimeUnit.SECONDS.toMillis(30L))) {
|
||||||
|
log.info("Disconnecting session {} for being inactive", sessionId);
|
||||||
client.getSession().close(CloseStatus.NOT_ACCEPTABLE.withReason("Client is inactive"));
|
client.getSession().close(CloseStatus.NOT_ACCEPTABLE.withReason("Client is inactive"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (client.getListeningTo() == null) {
|
if (client.getListeningTo() == null) {
|
||||||
|
System.err.println("NOT LISTENING!!!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Notify the listening client of the user's status if it has changed
|
// Notify the listening client of the user's status if it has changed
|
||||||
try {
|
try {
|
||||||
DiscordUser user = discordService.getUserBySnowflake(client.getListeningTo()).getUser();
|
DiscordUser user = discordService.getUserBySnowflake(client.getListeningTo()).getUser();
|
||||||
|
System.out.println("user = " + user);
|
||||||
if (!user.equals(client.getLastUser())) {
|
if (!user.equals(client.getLastUser())) {
|
||||||
client.setLastUser(user);
|
client.setLastUser(user);
|
||||||
dispatch(client.getSession(), new UserStatusPacket(user));
|
dispatch(client.getSession(), new UserStatusPacket(user));
|
||||||
}
|
}
|
||||||
} catch (BadRequestException | ServiceUnavailableException | ResourceNotFoundException ex) {
|
} catch (BadRequestException | ServiceUnavailableException | ResourceNotFoundException ex) {
|
||||||
|
System.err.println(ex.getLocalizedMessage());
|
||||||
|
System.err.println("STOPPED LISTENING TO USER!!!!!!!!!!!!!!");
|
||||||
client.setListeningTo(null);
|
client.setListeningTo(null);
|
||||||
dispatch(client.getSession(), new ErrorMessagePacket(ex.getLocalizedMessage()));
|
dispatch(client.getSession(), new ErrorMessagePacket(ex.getLocalizedMessage()));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user