当前位置: 首页>>代码示例>>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;未经允许,请勿转载。