本文整理匯總了Java中org.apache.mina.core.session.IoSession.isClosing方法的典型用法代碼示例。如果您正苦於以下問題:Java IoSession.isClosing方法的具體用法?Java IoSession.isClosing怎麽用?Java IoSession.isClosing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.mina.core.session.IoSession
的用法示例。
在下文中一共展示了IoSession.isClosing方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: messageReceived
import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
/**
* Receives data from the remote host, passes to the handler if a handshake is in progress,
* otherwise passes on transparently.
*
* @param nextFilter the next filter in filter chain
* @param session the session object
* @param message the object holding the received data
*/
@Override
public void messageReceived(final NextFilter nextFilter, final IoSession session, final Object message)
throws ProxyAuthException {
ProxyLogicHandler handler = getProxyHandler(session);
synchronized (handler) {
IoBuffer buf = (IoBuffer) message;
if (handler.isHandshakeComplete()) {
// Handshake done - pass data on as-is
nextFilter.messageReceived(session, buf);
} else {
LOGGER.debug(" Data Read: {} ({})", handler, buf);
// Keep sending handshake data to the handler until we run out
// of data or the handshake is finished
while (buf.hasRemaining() && !handler.isHandshakeComplete()) {
LOGGER.debug(" Pre-handshake - passing to handler");
int pos = buf.position();
handler.messageReceived(nextFilter, buf);
// Data not consumed or session closing
if (buf.position() == pos || session.isClosing()) {
return;
}
}
// Pass on any remaining data to the next filter
if (buf.hasRemaining()) {
LOGGER.debug(" Passing remaining data to next filter");
nextFilter.messageReceived(session, buf);
}
}
}
}
示例2: sessionIdle
import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
System.out.println("sessionIdle……");
if(session.isClosing()){
System.out.println("sessionIdle Closed");
}else{
if((System.currentTimeMillis()-session.getLastReadTime())>1000*60*2){
System.err.println(session.getId()+" ----------------Out of time, close user session");
session.close(true);
}
}
}
示例3: removeOutGame
import org.apache.mina.core.session.IoSession; //導入方法依賴的package包/類
public static void removeOutGame(String name) {
IoSession ss = outGame.remove(name);
if (ss != null) {
if (!ss.isClosing()) {
broadcastOutGame(GMPacketCreator.removeUser(name), null);
broadcastOutGame(GMPacketCreator.chat(name + " has logged out."), null);
}
}
}