javax.websocket.DeploymentException#javax.websocket.OnClose源码实例Demo

下面列出了javax.websocket.DeploymentException#javax.websocket.OnClose 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: LearningWebsocketServer.java
/**
    * 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()
			    : ""));
}
   }
 
源代码2 项目: lams   文件: LearningWebsocketServer.java
/**
    * 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()
			    : ""));
}
   }
 
源代码3 项目: lams   文件: LearningWebsocketServer.java
/**
    * 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()
			    : ""));
}
   }
 
源代码4 项目: lams   文件: PresenceWebsocketServer.java
/**
    * 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)"));
}
   }
 
源代码5 项目: lams   文件: KumaliveWebsocketServer.java
@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);
   }
 
源代码6 项目: lams   文件: CommandWebsocketServer.java
/**
    * 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);
   }
 
源代码7 项目: lams   文件: LearningWebsocketServer.java
/**
    * 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()
				    : ""));
}
   }
 
源代码8 项目: lams   文件: LearningWebsocketServer.java
/**
    * 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()
			    : ""));
}
   }
 
源代码9 项目: lams   文件: LearningWebsocketServer.java
/**
    * 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()
			    : ""));
}
   }
 
源代码10 项目: webChat   文件: webServer.java
@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);
}
 
源代码11 项目: liberty-bikes   文件: GameRoundWebsocket.java
@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();
    }
}
 
源代码12 项目: Tomcat8-Source-Read   文件: ChatAnnotation.java
@OnClose
public void end() {
    connections.remove(this);
    String message = String.format("* %s %s",
            nickname, "has disconnected.");
    broadcast(message);
}
 
源代码13 项目: Tomcat8-Source-Read   文件: ChatAnnotation.java
@OnClose
public void end() {
    connections.remove(this);
    String message = String.format("* %s %s",
            nickname, "has disconnected.");
    broadcast(message);
}
 
源代码14 项目: quarkus-http   文件: AnnotatedEndpointFactory.java
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;
    }
 
源代码15 项目: grain   文件: WebSocketServer.java
@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);
		}
	}
}
 
源代码16 项目: jeecg-cloud   文件: WebSocket.java
@OnClose
  public void onClose() {
      try {
	webSockets.remove(this);
	log.info("【websocket消息】连接断开,总数为:"+webSockets.size());
} catch (Exception e) {
}
  }
 
源代码17 项目: jeecg-boot-with-activiti   文件: WebSocket.java
@OnClose
  public void onClose() {
      try {
	webSockets.remove(this);
	log.info("【websocket消息】连接断开,总数为:"+webSockets.size());
} catch (Exception e) {
}
  }
 
源代码18 项目: teaching   文件: WebSocket.java
@OnClose
  public void onClose() {
      try {
	webSockets.remove(this);
	log.info("【websocket消息】连接断开,总数为:"+webSockets.size());
} catch (Exception e) {
}
  }
 
源代码19 项目: uyuni   文件: RemoteMinionCommands.java
/**
 * 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"));
    }

}
 
@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);
  }
}
 
源代码21 项目: jeecg-boot   文件: WebSocket.java
@OnClose
  public void onClose() {
      try {
	webSockets.remove(this);
	log.info("【websocket消息】连接断开,总数为:"+webSockets.size());
} catch (Exception e) {
}
  }
 
@OnClose
public void onClose () {
    clientWebSet.remove(this);
    subOnlineNumber();
    logger.info("a man out , now has :" + getOnlineNumber());
    this.infoAllClient();
}
 
@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());
}
 
源代码24 项目: OneBlog   文件: ZydWebsocketServer.java
/**
 * 连接关闭调用的方法
 */
@OnClose
public void onClose() {
    int count = onlineCount.decrementAndGet();
    log.info("[Socket] 有链接关闭,当前在线人数为: {}", count);
    WebSocketUtil.sendOnlineMsg(Integer.toString(count), webSocketSet);
}
 
源代码25 项目: MicroCommunity   文件: MessageWebsocket.java
/**
 * 连接关闭调用的方法
 */
@OnClose
public void onClose() {
    if (webSocketMap.containsKey(userId)) {
        webSocketMap.remove(userId);
        //从set中删除
        subOnlineCount();
    }
    logger.info("用户退出:" + userId + ",当前在线人数为:" + getOnlineCount());
}
 
源代码26 项目: testgrid   文件: ClientEndpoint.java
/**
 * 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();
}
 
源代码27 项目: belling-admin   文件: OnlineNoticeServer.java
/**
 * 连接关闭调用的方法-与前端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); // 广播
}
 
源代码28 项目: rogue-cloud   文件: WebSocketClientEndpoint.java
@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));
}
 
源代码29 项目: cjs_ssms   文件: WebSocketController.java
/**
 * 连接关闭调用的方法
 */
@OnClose
public void onClose() {
  webSocketSet.remove(this);  //从set中删除
  subOnlineCount();           //在线数减1
  log.debug("有一连接关闭!当前在线人数为" + getOnlineCount());
}
 
源代码30 项目: grain   文件: WebSocketServer.java
@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);
		}
	}
}