Пример #1
0
 protected virtual void OnClientAccept(AcceptEventArgs e)
 {
     if (this.ClientAccept != null)
     {
         this.ClientAccept(this, e);
     }
 }
Пример #2
0
        private void ProcessAccept(Socket socket)
        {
            TcpClient       tcpClient       = Activator.CreateInstance <TClient>();
            AcceptEventArgs acceptEventArgs = new AcceptEventArgs(tcpClient);

            try
            {
                this.OnClientAccept(acceptEventArgs);
                if (acceptEventArgs.Cancel)
                {
                    socket.Close();
                }
                else
                {
                    if (acceptEventArgs.JobProcessor == null)
                    {
                        acceptEventArgs.JobProcessor = this.jobProcessor;
                    }
                    if (this.DoOnHugeMessage != null)
                    {
                        acceptEventArgs.PacketAnalyzer.OnHugeMessageReceive += this.DoOnHugeMessage;
                    }
                    if (this.WriteLogFunc != null)
                    {
                        acceptEventArgs.PacketAnalyzer.WriteLog += this.WriteLogFunc;
                    }
                    tcpClient.Activate(socket, acceptEventArgs.JobProcessor, acceptEventArgs.PacketAnalyzer);
                }
            }
            catch (Exception value)
            {
                socket.Close();
                this.OnExceptionOccur(new EventArgs <Exception>(value));
            }
        }