protected void CloseClientSocket(SocketAsyncEventArgs e) { Close(() => { if (e.SocketError == SocketError.ConnectionReset) { if (this is GameClient) { ServerShutDown?.Invoke(this, e); Console.WriteLine("服务器主动断开"); } else { Console.WriteLine("客户端异常断开"); } } if (e.SocketError == SocketError.ConnectionAborted) { Console.WriteLine("网络断开"); ClientInternetError?.Invoke(this, e); } if (e.SocketError == SocketError.Success) { Console.WriteLine("客户端正常断开"); } DisconnectCompleted?.Invoke(this, e); }); }
/// <summary> /// 服务器停止工作 /// </summary> /// <param name="reason"></param> private static void OpcService_ServerShutDown(string reason) { ServerShutDown?.Invoke(reason); }