本文整理匯總了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 );
}