示例#1
0
        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);
        }
示例#2
0
        public GnpListener(IGnpIDGenerator <TClientID> idGenerator)
        {
            gnpClient        = new GnpClient();
            this.idGenerator = idGenerator;

            Initialize();
        }
示例#3
0
 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;
 }
示例#5
0
 public ConnectionReceivedEventArgs(Object id, GnpClient gnpClient)
 {
     this.gnpClient = gnpClient;
     this.id        = id;
 }
示例#6
0
 public void SendDataTo(byte[] data, GnpClient gnpClient)
 {
     this.gnpClient.Send(data, gnpClient.Socket.RemoteEndPoint);
 }
 public EndPoint GenerateID(GnpClient gnpClient)
 {
     return(gnpClient.Socket.RemoteEndPoint);
 }