javax.websocket.Session#equals ( )源码实例Demo

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

源代码1 项目: Jpom   文件: AgentFileTailWatcher.java
/**
 * 关闭文件读取流
 *
 * @param fileName 文件名
 */
static void offlineFile(File fileName, Session session) {
    AgentFileTailWatcher<Session> agentFileTailWatcher = CONCURRENT_HASH_MAP.get(fileName);
    if (null == agentFileTailWatcher) {
        return;
    }
    Set<Session> socketSessions = agentFileTailWatcher.socketSessions;
    for (Session socketSession : socketSessions) {
        if (socketSession.equals(session)) {
            offline(socketSession);
            break;
        }
    }
    if (agentFileTailWatcher.socketSessions.isEmpty()) {
        agentFileTailWatcher.close();
    }

}
 
源代码2 项目: 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)"));
}
   }
 
源代码3 项目: scipio-erp   文件: ExampleWebSockets.java
@OnMessage
public void onMessage(Session session, String msg, boolean last) {
    try {
        if (session.isOpen()) {
            synchronized (clients) {
                for(Session client : clients){
                    if (!client.equals(session)){
                        client.getBasicRemote().sendText(msg);
                    }
                }
            }
        }
    } catch (IOException e) {
        try {
            session.close();
        } catch (IOException ioe) {
            Debug.logError(ioe.getMessage(), module);
        }
    }
}
 
源代码4 项目: haxademic   文件: Demo_JettyWebSocketServer.java
/**
 * This method is invoked when a new message is received
 * 
 * @param message Received string message
 * @param session  Client reference
 * @throws IOException
 */
@OnMessage
public void onMessage(String message, Session session)
		throws IOException {
	P.out("New message: " + message + " from client: " + session);
	synchronized (clients) {
		for (Session client : clients) {
			if (!client.equals(session)) {
				client.getBasicRemote().sendText(message);
			}
		}
	}
}
 
源代码5 项目: eplmp   文件: Room.java
private boolean isUser1Session(Session userSession) {
    return userSession != null && userSession1 != null && userSession.equals(userSession1.getUserSession());
}
 
源代码6 项目: eplmp   文件: Room.java
private boolean isUser2Session(Session userSession) {
    return userSession != null && userSession2 != null && userSession.equals(userSession2.getUserSession());
}