javax.websocket.OnClose Java Examples
The following examples show how to use
javax.websocket.OnClose.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GameRoundWebsocket.java From liberty-bikes with Eclipse Public License 1.0 | 7 votes |
@OnClose public void onClose(@PathParam("roundId") String roundId, Session session) { log(roundId, "Closed a session"); if (timerContext != null) timerContext.close(); try { GameRound round = gameSvc.getRound(roundId); if (round != null) if (round.removeClient(session) == 0) gameSvc.deleteRound(round); } catch (Exception e) { e.printStackTrace(); } }
Example #2
Source File: LearningWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * When user leaves the activity. */ @OnClose public void unregisterUser(Session websocket, CloseReason reason) { Long toolSessionId = Long .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0)); LearningWebsocketServer.websockets.get(toolSessionId).remove(websocket); if (LearningWebsocketServer.log.isDebugEnabled()) { // If there was something wrong with the connection, put it into logs. LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName() + " left Mindmap with Tool Session ID: " + toolSessionId + (!(reason.getCloseCode().equals(CloseCodes.GOING_AWAY) || reason.getCloseCode().equals(CloseCodes.NORMAL_CLOSURE)) ? ". Abnormal close. Code: " + reason.getCloseCode() + ". Reason: " + reason.getReasonPhrase() : "")); } }
Example #3
Source File: PresenceWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * If there was something wrong with the connection, put it into logs. */ @OnClose public void unregisterUser(Session websocket, CloseReason reason) { Long lessonId = (Long) websocket.getUserProperties().get(AttributeNames.PARAM_LESSON_ID); Set<Session> lessonWebsockets = PresenceWebsocketServer.websockets.get(lessonId); Iterator<Session> sessionIterator = lessonWebsockets.iterator(); while (sessionIterator.hasNext()) { Session storedSession = sessionIterator.next(); if (storedSession.equals(websocket)) { sessionIterator.remove(); break; } } if (PresenceWebsocketServer.log.isDebugEnabled()) { PresenceWebsocketServer.log.debug("User " + websocket.getUserProperties().get(PARAM_NICKNAME) + " left Presence Chat with lessonId: " + lessonId + (!(reason.getCloseCode().equals(CloseCodes.GOING_AWAY) || reason.getCloseCode().equals(CloseCodes.NORMAL_CLOSURE)) ? ". Abnormal close. Code: " + reason.getCloseCode() + ". Reason: " + reason.getReasonPhrase() : "(unknown)")); } }
Example #4
Source File: KumaliveWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
@OnClose public void unregisterUser(Session websocket, CloseReason reason) throws IOException { String login = websocket.getUserPrincipal().getName(); if (login == null) { return; } Integer organisationId = Integer .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_ORGANISATION_ID).get(0)); KumaliveDTO kumalive = kumalives.get(organisationId); if (kumalive == null) { return; } KumaliveWebsocketServer.unregisterUser(kumalive, login); KumaliveWebsocketServer.sendRefresh(kumalive); }
Example #5
Source File: CommandWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Removes Learner websocket from the collection. */ @OnClose public void unregisterUser(Session session, CloseReason reason) { String login = session.getUserPrincipal().getName(); if (login == null) { return; } Long lessonId = Long.valueOf(session.getRequestParameterMap().get(AttributeNames.PARAM_LESSON_ID).get(0)); Map<String, Session> lessonWebsockets = CommandWebsocketServer.websockets.get(lessonId); if (lessonWebsockets == null) { return; } lessonWebsockets.remove(login); }
Example #6
Source File: LearningWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * When user leaves the activity. */ @OnClose public void unregisterUser(Session session, CloseReason reason) { Long toolSessionId = Long .valueOf(session.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0)); Set<Websocket> sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId); Iterator<Websocket> websocketIterator = sessionWebsockets.iterator(); while (websocketIterator.hasNext()) { Websocket websocket = websocketIterator.next(); if (websocket.session.equals(session)) { websocketIterator.remove(); break; } } if (LearningWebsocketServer.log.isDebugEnabled()) { LearningWebsocketServer.log.debug( "User " + session.getUserPrincipal().getName() + " left Chat with toolSessionId: " + toolSessionId + (!(reason.getCloseCode().equals(CloseCodes.GOING_AWAY) || reason.getCloseCode().equals(CloseCodes.NORMAL_CLOSURE)) ? ". Abnormal close. Code: " + reason.getCloseCode() + ". Reason: " + reason.getReasonPhrase() : "")); } }
Example #7
Source File: LearningWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * When user leaves the activity. */ @OnClose public void unregisterUser(Session websocket, CloseReason reason) { Long toolSessionId = Long .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0)); websockets.get(toolSessionId).remove(websocket); if (log.isDebugEnabled()) { // If there was something wrong with the connection, put it into logs. log.debug("User " + websocket.getUserPrincipal().getName() + " left Leader Selection with Tool Session ID: " + toolSessionId + (!(reason.getCloseCode().equals(CloseCodes.GOING_AWAY) || reason.getCloseCode().equals(CloseCodes.NORMAL_CLOSURE)) ? ". Abnormal close. Code: " + reason.getCloseCode() + ". Reason: " + reason.getReasonPhrase() : "")); } }
Example #8
Source File: LearningWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * When user leaves the activity. */ @OnClose public void unregisterUser(Session websocket, CloseReason reason) { Long toolSessionId = Long .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0)); LearningWebsocketServer.websockets.get(toolSessionId).remove(websocket); if (log.isDebugEnabled()) { // If there was something wrong with the connection, put it into logs. log.debug("User " + websocket.getUserPrincipal().getName() + " left Scratchie with Tool Session ID: " + toolSessionId + (!(reason.getCloseCode().equals(CloseCodes.GOING_AWAY) || reason.getCloseCode().equals(CloseCodes.NORMAL_CLOSURE)) ? ". Abnormal close. Code: " + reason.getCloseCode() + ". Reason: " + reason.getReasonPhrase() : "")); } }
Example #9
Source File: LearningWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * When user leaves the activity. */ @OnClose public void unregisterUser(Session websocket, CloseReason reason) { Long toolSessionId = Long .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0)); LearningWebsocketServer.websockets.get(toolSessionId).remove(websocket); if (LearningWebsocketServer.log.isDebugEnabled()) { // If there was something wrong with the connection, put it into logs. LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName() + " left Scribe with Tool Session ID: " + toolSessionId + (!(reason.getCloseCode().equals(CloseCodes.GOING_AWAY) || reason.getCloseCode().equals(CloseCodes.NORMAL_CLOSURE)) ? ". Abnormal close. Code: " + reason.getCloseCode() + ". Reason: " + reason.getReasonPhrase() : "")); } }
Example #10
Source File: webServer.java From webChat with Apache License 2.0 | 6 votes |
@OnClose public void close(Session session) { SocketUser user = new SocketUser(); user.setSession(session); user.setUserId(0); // 移除该用户 int uid = WebChatFactory.createManager().removeUser(user); user.setUserId(uid); userLogService.insertLog(user, UserLogType.LOGOUT); System.out.println("用户掉线" + uid); // print("当前在线用户:" + WebChatFactory.createManager().getOnlineCount()); // print("缓存中的用户个数:" + new OnLineUserManager().getOnLineUsers().size()); //通知所有人 String message = MessageParse.ServiceOnlineStatus(uid, OnlineStatus.OFFLINE); WebChatFactory.createManager().notifyOthers(user, message); }
Example #11
Source File: LearningWebsocketServer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * When user leaves the activity. */ @OnClose public void unregisterUser(Session websocket, CloseReason reason) { Long toolContentID = Long .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_CONTENT_ID).get(0)); websockets.get(toolContentID).remove(websocket); if (log.isDebugEnabled()) { // If there was something wrong with the connection, put it into logs. log.debug("User " + websocket.getUserPrincipal().getName() + " left Dokumaran with Tool Content ID: " + toolContentID + (!(reason.getCloseCode().equals(CloseCodes.GOING_AWAY) || reason.getCloseCode().equals(CloseCodes.NORMAL_CLOSURE)) ? ". Abnormal close. Code: " + reason.getCloseCode() + ". Reason: " + reason.getReasonPhrase() : "")); } }
Example #12
Source File: AnnotatedEndpointFactory.java From quarkus-http with Apache License 2.0 | 5 votes |
private AnnotatedEndpointFactory(final Class<?> endpointClass, final BoundMethod OnOpen, final BoundMethod OnClose, final BoundMethod OnError, final BoundMethod textMessage, final BoundMethod binaryMessage, final BoundMethod pongMessage) { this.endpointClass = endpointClass; this.OnOpen = OnOpen; this.OnClose = OnClose; this.OnError = OnError; this.textMessage = textMessage; this.binaryMessage = binaryMessage; this.pongMessage = pongMessage; }
Example #13
Source File: WebSocket.java From jeecg-cloud with Apache License 2.0 | 5 votes |
@OnClose public void onClose() { try { webSockets.remove(this); log.info("【websocket消息】连接断开,总数为:"+webSockets.size()); } catch (Exception e) { } }
Example #14
Source File: OnlineNoticeServer.java From belling-admin with Apache License 2.0 | 5 votes |
/** * 连接关闭调用的方法-与前端JS代码对应 */ @OnClose public void onClose() { webSocketSet.remove(this); // 从set中删除 routetabMap.remove(userid); OnlineUserlist.remove(userid); System.out.println(userid + " -> 已下线"); String message = getMessage(userid + " -> 已下线", "notice", OnlineUserlist); broadcast(message); //singleSend(message, sn); // 广播 }
Example #15
Source File: WebSocketClientEndpoint.java From rogue-cloud with Apache License 2.0 | 5 votes |
@OnClose public void close(Session session) { System.out.println("close."); // If the websocket was added as a managed resource, it can now be removed. ResourceLifecycleUtil.getInstance().removeSession(ServerWsClientUtil.convertSessionToManagedResource(session)); }
Example #16
Source File: WebSocketController.java From cjs_ssms with GNU General Public License v2.0 | 5 votes |
/** * 连接关闭调用的方法 */ @OnClose public void onClose() { webSocketSet.remove(this); //从set中删除 subOnlineCount(); //在线数减1 log.debug("有一连接关闭!当前在线人数为" + getOnlineCount()); }
Example #17
Source File: ChatAnnotation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@OnClose public void end() { connections.remove(this); String message = String.format("* %s %s", nickname, "has disconnected."); broadcast(message); }
Example #18
Source File: WebSocketServer.java From grain with MIT License | 5 votes |
@OnClose public void onClose(Session session, CloseReason closeReason) { try { ThreadMsgManager.dispatchThreadMsg(WSMsg.WEBSOCKET_CLIENT_DISCONNECT, null, session); } catch (Exception e) { if (WSManager.log != null) { WSManager.log.error("MsgManager.dispatchMsg error", e); } } }
Example #19
Source File: WebSocketServer.java From grain with MIT License | 5 votes |
@OnClose public void onClose(Session session, CloseReason closeReason) { try { MsgManager.dispatchMsg(WSMsg.WEBSOCKET_CLIENT_DISCONNECT, null, session); } catch (Exception e) { if (WSManager.log != null) { WSManager.log.error("MsgManager.dispatchMsg error", e); } } }
Example #20
Source File: WebSocket.java From jeecg-boot-with-activiti with MIT License | 5 votes |
@OnClose public void onClose() { try { webSockets.remove(this); log.info("【websocket消息】连接断开,总数为:"+webSockets.size()); } catch (Exception e) { } }
Example #21
Source File: WebSocket.java From teaching with Apache License 2.0 | 5 votes |
@OnClose public void onClose() { try { webSockets.remove(this); log.info("【websocket消息】连接断开,总数为:"+webSockets.size()); } catch (Exception e) { } }
Example #22
Source File: RemoteMinionCommands.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Callback executed when the websocket is closed. */ @OnClose public void onClose() { LOG.debug("Closing web socket session"); if (this.failAfter != null) { this.failAfter.completeExceptionally( new TimeoutException("Canceled waiting because of websocket close")); } }
Example #23
Source File: WSQueryEndpoint.java From ksql-fork-with-deep-learning-function with Apache License 2.0 | 5 votes |
@OnClose public void onClose(Session session, CloseReason closeReason) { log.debug( "Closing websocket session {} ({}): {}", session.getId(), closeReason.getCloseCode(), closeReason.getReasonPhrase() ); if (future != null) { future.cancel(true); } }
Example #24
Source File: ClientEndpoint.java From testgrid with Apache License 2.0 | 5 votes |
/** * Callback hook for Connection close events. * * @param userSession the userSession which is getting closed. * @param reason the reason for connection close */ @OnClose public void onClose(Session userSession, CloseReason reason) { logger.info("Closing web socket session: '" + userSession.getId() + "'. Code: " + reason.getCloseCode().toString() + " Reason: " + reason.getReasonPhrase()); this.userSession = null; if (hasClientConnected && !isShuttingDown) { hasClientConnected = false; logger.info("Retrying to connect."); connectClient(); } executorService.shutdown(); }
Example #25
Source File: WebSocket.java From jeecg-boot with Apache License 2.0 | 5 votes |
@OnClose public void onClose() { try { webSockets.remove(this); log.info("【websocket消息】连接断开,总数为:"+webSockets.size()); } catch (Exception e) { } }
Example #26
Source File: ChatAnnotation.java From Tomcat8-Source-Read with MIT License | 5 votes |
@OnClose public void end() { connections.remove(this); String message = String.format("* %s %s", nickname, "has disconnected."); broadcast(message); }
Example #27
Source File: OnlineNumberSocketServer.java From synchronizing-doc-convert-results with Apache License 2.0 | 5 votes |
@OnClose public void onClose () { clientWebSet.remove(this); subOnlineNumber(); logger.info("a man out , now has :" + getOnlineNumber()); this.infoAllClient(); }
Example #28
Source File: ConvertingResultSocketServer.java From synchronizing-doc-convert-results with Apache License 2.0 | 5 votes |
@OnClose public void onClose () { Integer convertId = this.convertId; sessionPool.remove(convertId.toString()); convertHashMap.remove(convertId); logger.info("convert job out , the convertId is :" + convertId.toString()); }
Example #29
Source File: ZydWebsocketServer.java From OneBlog with GNU General Public License v3.0 | 5 votes |
/** * 连接关闭调用的方法 */ @OnClose public void onClose() { int count = onlineCount.decrementAndGet(); log.info("[Socket] 有链接关闭,当前在线人数为: {}", count); WebSocketUtil.sendOnlineMsg(Integer.toString(count), webSocketSet); }
Example #30
Source File: MessageWebsocket.java From MicroCommunity with Apache License 2.0 | 5 votes |
/** * 连接关闭调用的方法 */ @OnClose public void onClose() { if (webSocketMap.containsKey(userId)) { webSocketMap.remove(userId); //从set中删除 subOnlineCount(); } logger.info("用户退出:" + userId + ",当前在线人数为:" + getOnlineCount()); }