示例#1
0
        /// <summary>
        /// 客户端断开连接
        /// </summary>
        /// <param name="session"></param>
        /// <param name="reason"></param>
        private static void OnSessionClosed(CustomSession session, CloseReason reason)
        {
            switch (reason)
            {
            case CloseReason.Unknown:
                break;

            case CloseReason.ServerShutdown:
                break;

            case CloseReason.ClientClosing:
                break;

            case CloseReason.ServerClosing:
                break;

            case CloseReason.ApplicationError:
                break;

            case CloseReason.SocketError:
                break;

            case CloseReason.TimeOut:
                break;

            case CloseReason.ProtocolError:
                break;

            case CloseReason.InternalError:
                break;
            }
            Console.WriteLine($"客户端[{session.RemoteEndPoint.Address}:{session.RemoteEndPoint.Port}]关闭,原因:{reason.ToString()}");
        }
示例#2
0
 /// <summary>
 /// 有新客户端连接
 /// </summary>
 /// <param name="session"></param>
 private static void OnNewSessionConnected(CustomSession session)
 {
     Console.WriteLine($"新的客户端已经连接,{session.RemoteEndPoint.Address}:{session.RemoteEndPoint.Port}");
 }