/// <summary> /// 处理接收请求 /// </summary> private void ProcessAccept(object obj) { SocketAsyncEventArgs e = obj as SocketAsyncEventArgs; if (e.SocketError == SocketError.Success) { // 创建频道 TcpChannel channel = new TcpChannel(); channel.InitChannel(e.AcceptSocket, _packageCoderType, _packageMaxSize); // 加入到频道列表 lock (_allChannels) { _allChannels.Add(channel); } } else { MotionLog.Log(ELogLevel.Error, $"ProcessAccept error : {e.SocketError}"); } // 投递下一个接收请求 StartAccept(e); }
/// <summary> /// 初始化编码解码器 /// </summary> public void InitCoder(TcpChannel channel, int packageBodyMaxSize) { _channel = channel; PackageBodyMaxSize = packageBodyMaxSize; }