Ejemplo n.º 1
0
 private void ClientOnDataReceived(ClientRabbit client, IParserStruct structure)
 {
     if (DataReceived != null)
     {
         DataReceived(client, structure);
     }
 }
Ejemplo n.º 2
0
 public void DeleteClient(ClientRabbit client)
 {
     lock (_syncHandle)
     {
         _clients.Remove(client);
         //CloseClientSocket(client);
     }
 }
Ejemplo n.º 3
0
        private void InvokeOnConnected(ClientRabbit sender)
        {
            Action <ClientRabbit> connected = OnConnected;

            if (connected != null)
            {
                connected(sender);
            }
        }
Ejemplo n.º 4
0
        private void InvokeOnConnecting(ClientRabbit sender)
        {
            Action <ClientRabbit> connecting = OnConnecting;

            if (connecting != null)
            {
                connecting(sender);
            }
        }
Ejemplo n.º 5
0
        private void DoReceiveAsync(ClientRabbit client)
        {
            MethodInvoker async = delegate
            {
                try
                {
                    client.StartReceiving(client.Id);
                }
                catch (Exception ex)
                {
                    Log("EXCEPTION: DoReceiveAsync : " + ex.Message);
                }
            };

            async.BeginInvoke(CallBack, null);
        }
Ejemplo n.º 6
0
        public void AddClient(ClientRabbit messageId)
        {
            lock (_syncHandle)
            {
                int index = -1;
                //for (int i = 0; i < _clients.Count;i++ ) Log("[AddClient] socket.REP=" + ((IPEndPoint)socket.RemoteEndPoint).Address.ToString() + " _client[" + i + "].IP=" + _clients[i].IPadress.ToString());
                try
                {
                    index = _clients.IndexOf(_clients.Find(s => s.Id == messageId.Id));
                }
                catch (Exception) { }
                //Already exist channel!
                if (index != null && index != -1)
                {
                    DoLog("Client is already registered!");
                    return;
                }

                _clients.Add(messageId);

                //start receiving on this new socket
                DoReceiveAsync(_clients.Last());
            }
        }