本文整理汇总了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);
}
}
}
示例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;
}
示例3: onWebSocketConnect
import org.eclipse.jetty.websocket.api.Session; //导入方法依赖的package包/类
@Override
public void onWebSocketConnect(Session sess) {
super.onWebSocketConnect(sess);
sess.setIdleTimeout(10000);
}
示例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 );
}