本文整理汇总了Java中org.apache.mina.core.session.IoSession.closeOnFlush方法的典型用法代码示例。如果您正苦于以下问题:Java IoSession.closeOnFlush方法的具体用法?Java IoSession.closeOnFlush怎么用?Java IoSession.closeOnFlush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mina.core.session.IoSession
的用法示例。
在下文中一共展示了IoSession.closeOnFlush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sessionIdle
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
public void sessionIdle(IoSession session, IdleStatus status)throws Exception {
logger.info("客户端sessionIdle, " + (System.currentTimeMillis() - session.getLastReadTime()) + "毫秒没有上行。" + session.getRemoteAddress());
if((System.currentTimeMillis()-session.getLastReadTime())>1000*60*10){
Object userID = (Object)0;
if(session.containsAttribute("UserID")){
userID = session.getAttribute("UserID");
}
logger.info(" Player["+userID.toString()+"] -------------------------------------------Out of time, close user session lastReadTime:"+session.getLastReadTime()+"["+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:ms").format(new Date(session.getLastReadTime()))+"] now:"+System.currentTimeMillis()+"["+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:ms").format(new Date(System.currentTimeMillis()))+"] session:"+session.getRemoteAddress());
logger.info(session.getId()+" -----------------------------------------Out of time, close user session");
logger.info("System.currentTimeMillis():"+format(System.currentTimeMillis()));
logger.info("session.getLastIoTime():"+format(session.getLastIoTime()));
logger.info("session.getLastBothIdleTime():"+format(session.getLastBothIdleTime()));
logger.info("session.getLastReaderIdleTime():"+format(session.getLastReaderIdleTime()));
logger.info("session.getLastReadTime():"+format(session.getLastReadTime()));
logger.info("session.getLastWriterIdleTime():"+format(session.getLastWriterIdleTime()));
logger.info("session.getLastWriteTime():"+format(session.getLastWriteTime()));
session.closeOnFlush();
}
}
示例2: messageReceived
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void messageReceived(IoSession session, Object message) throws Exception {
String str = message.toString();
LOGGER.info("Recevied message: {}", str);
if (str.trim().startsWith("s:")) {
String data = "S:" + toHexString(boostDutyCycle) + "," + (boostSuccessful ? "0" : "1") + "," + toHexString(boostFreeMemorySlots);
LOGGER.info("Sending reply: {}", data);
session.write(data);
}
if( str.trim().equalsIgnoreCase("q:") ) {
session.closeOnFlush();
return;
}
}
示例3: onSessionClosed
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void onSessionClosed(IoSession session) {
if (session != null && session.isConnected())
session.closeOnFlush();
}