[Backend][taskNotifications]] Modfied for webscoket only transport and added logs (#5730)

This commit is contained in:
mohitdeuex 2022-06-29 23:20:54 +05:30 committed by GitHub
parent 1d7e212e2f
commit c4bac17b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,7 +32,15 @@ public class WebSocketManager {
"connection",
args -> {
SocketIoSocket socket = (SocketIoSocket) args[0];
String userId = socket.getInitialHeaders().get("UserId").get(0);
final String userId;
String tempId;
try {
tempId = socket.getInitialHeaders().get("UserId").get(0);
} catch (Exception ex) {
tempId = socket.getInitialQuery().get("userId");
}
userId = tempId;
if (userId != null && !userId.equals("")) {
LOG.info(
"Client :"
@ -57,6 +65,27 @@ public class WebSocketManager {
allUserConnection.remove(socket.getId());
activityFeedEndpoints.put(id, allUserConnection);
});
socket.on(
"connect_error",
args1 -> {
LOG.error(
"Connection ERROR for user:"
+ userId
+ "with Remote Address :"
+ socket.getInitialHeaders().get("RemoteAddress")
+ " disconnected.");
});
socket.on(
"connect_failed",
args1 -> {
LOG.error(
"Connection failed ERROR for user:"
+ userId
+ "with Remote Address :"
+ socket.getInitialHeaders().get("RemoteAddress")
+ " disconnected.");
});
UUID id = UUID.fromString(userId);
Map<String, SocketIoSocket> userSocketConnections;
userSocketConnections =
@ -65,6 +94,11 @@ public class WebSocketManager {
activityFeedEndpoints.put(id, userSocketConnections);
}
});
ns.on(
"error",
args -> {
LOG.error("Connection error on the server");
});
}
public static WebSocketManager getInstance() {