private void ClientOnDataReceived(ClientRabbit client, IParserStruct structure) { if (DataReceived != null) { DataReceived(client, structure); } }
public void DeleteClient(ClientRabbit client) { lock (_syncHandle) { _clients.Remove(client); //CloseClientSocket(client); } }
private void InvokeOnConnected(ClientRabbit sender) { Action <ClientRabbit> connected = OnConnected; if (connected != null) { connected(sender); } }
private void InvokeOnConnecting(ClientRabbit sender) { Action <ClientRabbit> connecting = OnConnecting; if (connecting != null) { connecting(sender); } }
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); }
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()); } }