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

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

            if (connecting != null)
            {
                connecting(sender);
            }
        }
Esempio 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);
        }
Esempio 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());
            }
        }