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