void gnpClient_DataReceived(object sender, DataReceivedEventArgs e) { // We received data from a client that hasn't been redirected yet TClientID id = idGenerator.GenerateID(e); int index = clientCollection.IndexOf(id); GnpClient dataClient = null; if (index > -1) { dataClient = clientCollection[index]; } else { dataClient = new GnpClient(e.DataSource); clientCollection.AddGnpClient(id, dataClient); if (ConnectionReceived != null) { ConnectionReceived(this, new ConnectionReceivedEventArgs(id, dataClient)); } } dataClient.InjectData(e.ByteData, e.DataSource); }
public GnpListener(IGnpIDGenerator <TClientID> idGenerator) { gnpClient = new GnpClient(); this.idGenerator = idGenerator; Initialize(); }
public void AddGnpClient(TClientID clientID, GnpClient gnpClient) { if (clients.ContainsKey(clientID) == false) { // If the collection does not contain a client with the same ID, add it clients.Add(clientID, gnpClient); } }
public ConnectionReceivedEventArgs(Object id, GnpClient gnpClient) { this.gnpClient = gnpClient; this.id = id; }
public void SendDataTo(byte[] data, GnpClient gnpClient) { this.gnpClient.Send(data, gnpClient.Socket.RemoteEndPoint); }
public EndPoint GenerateID(GnpClient gnpClient) { return(gnpClient.Socket.RemoteEndPoint); }