Java Code Examples for org.apache.mina.core.session.IoSession#closeOnFlush()
The following examples show how to use
org.apache.mina.core.session.IoSession#closeOnFlush() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerHandler.java From sumk with Apache License 2.0 | 6 votes |
@Override public void exceptionCaught(IoSession session, Throwable cause) { session.closeOnFlush(); if (cause == null) { return; } if (cause.getClass() == IOException.class && AppInfo.getBoolean("rpc.session.print_simple_error", true)) { String msg = cause.getMessage(); if (msg != null && (msg.contains("连接") || msg.contains("connection"))) { log.debug("session:{},message:{}", session.getId(), cause.getMessage()); return; } } log.error(session + ",message:" + cause.getMessage(), cause); }
Example 2
Source File: ServerHandler.java From seed with Apache License 2.0 | 5 votes |
@Override public void messageSent(IoSession session, Object message) throws Exception { LogUtil.getLogger().info("已回应给Client..."); if(session != null){ //session.close(true); session.closeOnFlush(); } }
Example 3
Source File: ClientHandler.java From sumk with Apache License 2.0 | 5 votes |
@Override public void sessionIdle(IoSession session, IdleStatus status) throws Exception { long time = System.currentTimeMillis() - session.getLastIoTime(); if (time > AppInfo.getLong(Const.SOA_SESSION_IDLE, 60) * 1000) { Log.get("sumk.rpc.client").info("rpc session {} {} for {}ms,closed by this client", session.getId(), status, session.getLastIoTime(), time); session.closeOnFlush(); } }
Example 4
Source File: ServerHandler.java From sumk with Apache License 2.0 | 5 votes |
@Override public void sessionIdle(IoSession session, IdleStatus status) { long time = System.currentTimeMillis() - session.getLastIoTime(); if (time > AppInfo.getLong(Const.SOA_SESSION_IDLE, 60) * 1000) { log.info("rpc session {} {} for {}ms,closed by this server", session.getId(), status, session.getLastIoTime(), time); session.closeOnFlush(); } }
Example 5
Source File: MTGGameRoomServer.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
private void join(IoSession session, JoinAction ja) { if (!getString(MAX_CLIENT).equals("0") && acceptor.getManagedSessions().size() >= getInt(MAX_CLIENT)) { session.write(new SpeakAction(null, "Number of users reached (" + getString(MAX_CLIENT) + ")")); session.closeOnFlush(); return; } ja.getPlayer().setState(STATE.CONNECTED); ja.getPlayer().setId(session.getId()); session.setAttribute(PLAYER, ja.getPlayer()); speak(new SpeakAction(ja.getPlayer(), " is now connected")); session.write(session.getId()); refreshPlayers(session); }
Example 6
Source File: NetManager.java From jane with GNU Lesser General Public License v3.0 | 5 votes |
/** * 安全地关闭session * <p> * 主要适合刚发送最后消息后即关闭连接时. 如果最后的消息发送超时则强制关闭 */ public static boolean closeOnFlush(IoSession session) { if (session.setAttributeIfAbsent("closeOnFlushTime", (int)_timeSec + Const.closeOnFlushTimeout) != null) return false; session.closeOnFlush(); _closings.offer(session); return true; }
Example 7
Source File: HttpServerIoHandler.java From game-server with MIT License | 4 votes |
/** {@inheritDoc} */ @Override public void sessionIdle(IoSession session, IdleStatus status) { session.closeOnFlush(); }
Example 8
Source File: HttpServerIoHandler.java From game-server with MIT License | 4 votes |
/** {@inheritDoc} */ @Override public void exceptionCaught(IoSession session, Throwable cause) { session.closeOnFlush(); LOG.debug("exceptionCaught", cause); }
Example 9
Source File: ServerHandler.java From seed with Apache License 2.0 | 4 votes |
@Override public void exceptionCaught(IoSession session, Throwable cause){ LogUtil.getLogger().error("请求处理遇到异常...回路即将关闭...", cause); //session.close(true); session.closeOnFlush(); }
Example 10
Source File: WebMessageDecoder.java From cim with Apache License 2.0 | 4 votes |
private void handleClose(IoSession iosession, IoBuffer in) { in.get(new byte[in.remaining()]); iosession.closeOnFlush(); }