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

            if (connected != null)
            {
                connected(sender);
            }
        }
예제 #4
0
        private void InvokeOnConnecting(ClientRabbit sender)
        {
            Action <ClientRabbit> connecting = OnConnecting;

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