Пример #1
0
        private void ListenLoop(object obj)
        {
            Socket listener = (Socket)obj;

            listener.Listen(_MaxClients);
            while (ShouldListen)
            {
                try
                {
                    TcpConnectionHandler tempClient = new TcpConnectionHandler(listener.Accept(), this._BufferSize);
                    tempClient.StartReceiving();
                    tempClient.DataReceived    += new EventHandler <NetworkDataEventArgs>(DataReceivedHandler);
                    tempClient.ReceiverStarted += new EventHandler <GenericEventArgs <EndPoint> >(ClientReceiverStarted);
                    tempClient.ReceiverStopped += new EventHandler <EventArgs>(ClientReceiverStopped);
                    tempClient.DataSent        += new EventHandler <NetworkDataEventArgs>(ClientDataSent);
                }
                catch (Exception ex)
                {
                    ShouldListen = false;
                    if (this.ExceptionCatched != null)
                    {
                        this.ExceptionCatched(this, new ExceptionEventArgs(ex));
                    }
                }
            }
        }
Пример #2
0
        private void StartProcessingData(object objs)
        {
            object[]             objArray = (object[])objs;
            byte[]               data     = (byte[])objArray[0];
            TcpConnectionHandler handler  = (TcpConnectionHandler)objArray[1];

            ProcessData(data, handler);
        }
Пример #3
0
 protected virtual void ProcessData(byte[] data, TcpConnectionHandler sender)
 {
 }
Пример #4
0
 private void ListenLoop(object obj)
 {
     Socket listener = (Socket)obj;
     listener.Listen(_MaxClients);
     while (ShouldListen)
     {
         try
         {
             TcpConnectionHandler tempClient = new TcpConnectionHandler(listener.Accept(),this._BufferSize);
             tempClient.StartReceiving();
             tempClient.DataReceived += new EventHandler<NetworkDataEventArgs>(DataReceivedHandler);
             tempClient.ReceiverStarted += new EventHandler<GenericEventArgs<EndPoint>>(ClientReceiverStarted);
             tempClient.ReceiverStopped += new EventHandler<EventArgs>(ClientReceiverStopped);
             tempClient.DataSent += new EventHandler<NetworkDataEventArgs>(ClientDataSent);
         }
         catch (Exception ex)
         {
             ShouldListen = false;
             if (this.ExceptionCatched != null) this.ExceptionCatched(this, new ExceptionEventArgs(ex));
         }
     }
 }
Пример #5
0
 protected virtual void ProcessData(byte[] data, TcpConnectionHandler sender)
 {
 }