下面列出了javax.websocket.DeploymentException#javax.websocket.OnClose 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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()
: ""));
}
}
/**
* 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()
: ""));
}
}
/**
* 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()
: ""));
}
}
/**
* 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)"));
}
}
@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);
}
/**
* 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);
}
/**
* 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()
: ""));
}
}
/**
* 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()
: ""));
}
}
/**
* 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()
: ""));
}
}
@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);
}
@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();
}
}
@OnClose
public void end() {
connections.remove(this);
String message = String.format("* %s %s",
nickname, "has disconnected.");
broadcast(message);
}
@OnClose
public void end() {
connections.remove(this);
String message = String.format("* %s %s",
nickname, "has disconnected.");
broadcast(message);
}
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;
}
@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);
}
}
}
@OnClose
public void onClose() {
try {
webSockets.remove(this);
log.info("【websocket消息】连接断开,总数为:"+webSockets.size());
} catch (Exception e) {
}
}
@OnClose
public void onClose() {
try {
webSockets.remove(this);
log.info("【websocket消息】连接断开,总数为:"+webSockets.size());
} catch (Exception e) {
}
}
@OnClose
public void onClose() {
try {
webSockets.remove(this);
log.info("【websocket消息】连接断开,总数为:"+webSockets.size());
} catch (Exception e) {
}
}
/**
* 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);
}
}
@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());
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose() {
int count = onlineCount.decrementAndGet();
log.info("[Socket] 有链接关闭,当前在线人数为: {}", count);
WebSocketUtil.sendOnlineMsg(Integer.toString(count), webSocketSet);
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose() {
if (webSocketMap.containsKey(userId)) {
webSocketMap.remove(userId);
//从set中删除
subOnlineCount();
}
logger.info("用户退出:" + userId + ",当前在线人数为:" + getOnlineCount());
}
/**
* 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();
}
/**
* 连接关闭调用的方法-与前端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); // 广播
}
@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));
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose() {
webSocketSet.remove(this); //从set中删除
subOnlineCount(); //在线数减1
log.debug("有一连接关闭!当前在线人数为" + getOnlineCount());
}
@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);
}
}
}