当前位置: 首页>>代码示例>>C#>>正文


C# IoSession.Close方法代码示例

本文整理汇总了C#中IoSession.Close方法的典型用法代码示例。如果您正苦于以下问题:C# IoSession.Close方法的具体用法?C# IoSession.Close怎么用?C# IoSession.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IoSession的用法示例。


在下文中一共展示了IoSession.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SessionCreated

 public override void SessionCreated(INextFilter nextFilter, IoSession session)
 {
     if (!IsConnectionOk(session))
     {
         Debug.WriteLine("Connections coming in too fast; closing.");
         session.Close(true);
     }
     base.SessionCreated(nextFilter, session);
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:9,代码来源:ConnectionThrottleFilter.cs

示例2: SessionCreated

 /// <inheritdoc/>
 public override void SessionCreated(INextFilter nextFilter, IoSession session)
 {
     if (!IsConnectionOk(session))
     {
         if (log.IsWarnEnabled)
             log.Warn("Connections coming in too fast; closing.");
         session.Close(true);
     }
     base.SessionCreated(nextFilter, session);
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:11,代码来源:ConnectionThrottleFilter.cs

示例3: ExceptionCaught

 public override void ExceptionCaught(INextFilter nextFilter, IoSession session, Exception cause)
 {
     Log.Error(ErrorCode.UnhandledExceptionCaught, cause);
     var counter = session.GetAttribute<int>(KeyName.SESSION_ERROR_COUNTER);
     if (counter >= MAX_UNCAUGHT_SESSION_ERROR_COUNT) session.Close(true);
     else
     {
         session.SetAttribute(KeyName.SESSION_ERROR_COUNTER, ++counter);
         base.ExceptionCaught(nextFilter, session, cause);
     }
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:11,代码来源:ExceptionCounterFilter.cs

示例4: MessageReceived

        /// <summary>
        /// If the message is 'quit', we exit by closing the session. Otherwise,
        /// we return the current date.
        /// </summary>
        public override void MessageReceived(IoSession session, Object message)
        {
            String str = message.ToString();

            // "Quit" ? let's get out ...
            if (str.Trim().Equals("quit", StringComparison.OrdinalIgnoreCase))
            {
                session.Close(true);
                return;
            }

            // Send the current date back to the client
            session.Write(DateTime.Now.ToString());
            Console.WriteLine("Message written...");
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:19,代码来源:TimeServerHandler.cs

示例5: ExceptionCaught

 public override void ExceptionCaught(IoSession session, Exception cause)
 {
     IOException ioe = cause as IOException;
     if (ioe != null)
     {
         IoSessionStream input = session.GetAttribute<IoSessionStream>(KEY_IN);
         if (input != null)
         {
             input.Exception = ioe;
             return;
         }
     }
     Debug.WriteLine("Unexpected exception. {0}", cause);
     session.Close(true);
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:15,代码来源:StreamIoHandler.cs

示例6: MessageReceived

        public override void MessageReceived(IoSession session, Object message)
        {
            Console.WriteLine("Player-" + id + ": RCVD " + message);

            TennisBall ball = (TennisBall)message;

            // Stroke: TTL decreases and PING/PONG state changes.
            ball = ball.Stroke();

            if (ball.TTL > 0)
            {
                // If the ball is still alive, pass it back to peer.
                session.Write(ball);
            }
            else
            {
                // If the ball is dead, this player loses.
                Console.WriteLine("Player-" + id + ": LOSE");
                session.Close(true);
            }
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:21,代码来源:TennisPlayer.cs

示例7: FinishSessionInitialization0

 /// <inheritdoc/>
 protected override void FinishSessionInitialization0(IoSession session, IoFuture future)
 {
     // In case that IConnectFuture.Cancel() is invoked before
     // SetSession() is invoked, add a listener that closes the
     // connection immediately on cancellation.
     future.Complete += (s, e) =>
     {
         if (((IConnectFuture)e.Future).Canceled)
             session.Close(true);
     };
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:12,代码来源:AbstractIoConnector.cs

示例8: InputClosed

 /// <inheritdoc/>
 public void InputClosed(IoSession session)
 {
     session.Close(true);
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:5,代码来源:IoHandlerAdapter.cs

示例9: BlockSession

 private void BlockSession(IoSession session)
 {
     if (log.IsWarnEnabled)
         log.Warn("Remote address in the blacklist; closing.");
     session.Close(true);
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:6,代码来源:BlacklistFilter.cs

示例10: KeepAliveRequestTimedOut

 public void KeepAliveRequestTimedOut(KeepAliveFilter filter, IoSession session)
 {
     Debug.WriteLine("Closing the session because a keep-alive response message was not received within {0} second(s).",
         filter.RequestTimeout);
     session.Close(true);
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:6,代码来源:KeepAliveRequestTimeoutHandler.cs

示例11: ExceptionCaught

        /// <inheritdoc/>
        public override void ExceptionCaught(IoSession session, Exception cause)
        {
            IOException ioe = cause as IOException;
            if (ioe != null)
            {
                IoSessionStream input = session.GetAttribute<IoSessionStream>(KEY_IN);
                if (input != null)
                {
                    input.Exception = ioe;
                    return;
                }
            }

            if (log.IsWarnEnabled)
                log.Warn("Unexpected exception.", cause);
            session.Close(true);
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:18,代码来源:StreamIoHandler.cs

示例12: SessionIdle

 public override void SessionIdle(INextFilter nextFilter, IoSession session, IdleStatus status)
 {
     if (status == IdleStatus.ReaderIdle) session.Close(true);
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:4,代码来源:SessionAbnormalFilter.cs

示例13: ExceptionCaught

 public override void ExceptionCaught(IoSession session, Exception cause)
 {
     session.Close(true);
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:4,代码来源:AbstractBindTest.cs

示例14: KeepAliveRequestTimedOut

 public void KeepAliveRequestTimedOut(KeepAliveFilter filter, IoSession session)
 {
     if (log.IsWarnEnabled)
         log.WarnFormat("Closing the session because a keep-alive response message was not received within {0} second(s).",
             filter.RequestTimeout);
     session.Close(true);
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:7,代码来源:KeepAliveRequestTimeoutHandler.cs

示例15: ExceptionCaught

 public override void ExceptionCaught(IoSession session, Exception cause)
 {
     Console.WriteLine(cause);
     session.Close(true);
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:5,代码来源:TennisPlayer.cs


注:本文中的IoSession.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。