Exemple #1
0
        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);
            }
        }
Exemple #2
0
        /// <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);
        }