private void ProcessConnected(object obj) { SocketAsyncEventArgs e = obj as SocketAsyncEventArgs; //如果失败 if (e.SocketError != SocketError.Success) { MoLog.Log(ELogType.Error, "ProcessConnected error : {0}", e.SocketError); return; } //创建频道 MoTChannel channel = new MoTChannel(); channel.InitSocket(e.ConnectSocket); //加入到频道列表 lock (_allChannels) { _allChannels.Add(channel); } }
/// <summary> /// 处理Accept请求 /// </summary> private void ProcessAccept(object obj) { SocketAsyncEventArgs e = obj as SocketAsyncEventArgs; //如果失败 if (e.SocketError != SocketError.Success) { MoLog.Log(ELogType.Error, "ProcessConnected error : {0}", e.SocketError); return; } //创建频道 MoTChannel channel = new MoTChannel(); channel.InitSocket(e.AcceptSocket); //添加频道 AddChannel(channel); // 投递下一个接收请求 StartAccept(e); }