當前位置: 首頁>>代碼示例>>Java>>正文


Java Session.setIdleTimeout方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.websocket.api.Session.setIdleTimeout方法的典型用法代碼示例。如果您正苦於以下問題:Java Session.setIdleTimeout方法的具體用法?Java Session.setIdleTimeout怎麽用?Java Session.setIdleTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.websocket.api.Session的用法示例。


在下文中一共展示了Session.setIdleTimeout方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerSession

import org.eclipse.jetty.websocket.api.Session; //導入方法依賴的package包/類
/**
 *
 * Stores all websocket client sessions in the internal map 'sessionMap'.
 *
 * Note sessions are 'internally' identified using the encrypted handshake 'Sec-WebSocket-Accept' value and
 * 'externally' identified using an allocated UUID.
 *
 *
 * @param mockExtId
 * @param path
 * @param idleTimeoutMillis
 * @param session
 *
 */
public void registerSession(final String mockExtId, final String path, final long idleTimeoutMillis, final boolean proxyPushIdOnConnect, final Session session) {
    logger.debug("registerSession called");

    session.setIdleTimeout((idleTimeoutMillis > 0) ? idleTimeoutMillis : MAX_IDLE_TIMEOUT_MILLIS );

    final Set<SessionIdWrapper> sessions = sessionMap.getOrDefault(path, new HashSet<SessionIdWrapper>());

    final String assignedId = GeneralUtils.generateUUID();

    sessions.add(new SessionIdWrapper(assignedId, session, GeneralUtils.getCurrentDate()));

    sessionMap.put(path, sessions);

    if (proxyPushIdOnConnect) {
        try {
            sendMessage(assignedId, new WebSocketDTO(path, "clientId: " + assignedId));
        } catch (IOException ex) {
            logger.error("Error pushing client id to client on 1st connect", ex);
        }
    }

}
 
開發者ID:mgtechsoftware,項目名稱:smockin,代碼行數:37,代碼來源:WebSocketServiceImpl.java

示例2: addClient

import org.eclipse.jetty.websocket.api.Session; //導入方法依賴的package包/類
/**
 * Add a client to the list of connected clients. Each client gets an ID,
 * which the client manger communicate to the client via JSON-RPC
 * notification. This ID can be used for further communication if necessary.
 *
 * @param session
 *            Session from Jetty.
 * @return the newly created client's id
 */
@Override
public int addClient(final Session session) {
	int clientId = generateClientId();
	session.setIdleTimeout(TIMEOUT);
	sessions.put(clientId, session);
	notifyClientAboutId(clientId);
	String msg = "new client has connected to server, id: " + clientId;
	notifyAllClients(msg);

	String ipAddress = session.getRemoteAddress().getHostString();
	clientInformationHandler.addConnection(ipAddress,clientId);
	// Notify Observers, e.g. Developer Settings Handler so that the connected users list can be updated
	setChanged();
	notifyObservers();
	return clientId;
}
 
開發者ID:weiss19ja,項目名稱:amos-ss16-proj2,代碼行數:26,代碼來源:ClientManagerImpl.java

示例3: onWebSocketConnect

import org.eclipse.jetty.websocket.api.Session; //導入方法依賴的package包/類
@Override
public void onWebSocketConnect(Session sess) {
    super.onWebSocketConnect(sess);
    sess.setIdleTimeout(10000);
}
 
開發者ID:amaralDaniel,項目名稱:megaphone,代碼行數:6,代碼來源:EchoSocket.java

示例4: onWebSocketConnect

import org.eclipse.jetty.websocket.api.Session; //導入方法依賴的package包/類
@Override
public void onWebSocketConnect( final Session session )
{
    session.setIdleTimeout( this.config.getTimeout() );
    this.session = newSession( session );

    final WebSocketEvent event = newEventBuilder().
        openEvent().
        build();

    handleEvent( event );
}
 
開發者ID:purplejs,項目名稱:purplejs,代碼行數:13,代碼來源:WebSocketHandler.java


注:本文中的org.eclipse.jetty.websocket.api.Session.setIdleTimeout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。