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