Exemplo n.º 1
0
 private void M_Node_OnPacketDrop(NetworkPacket packet)
 {
     if (m_RemoteAdapters.ContainsKey(packet.Receiver.NetworkAddress))
     {
         Log("Routing Packet through tunnel '{0}'", m_Client.Client.RemoteEndPoint);
         List <byte> request = new List <byte>();
         request.Add(( byte )NetworkNodeRequestType.SEND);
         byte[] data = packet.Serialize();
         request.AddRange(BitConverter.GetBytes(data.Length));
         request.AddRange(data);
         m_Client.GetStream().Write(request.ToArray(), 0, request.Count);
     }
 }
Exemplo n.º 2
0
        public void Send(NetworkPacket p)
        {
            if (m_LocalAdapters.TryGetValue(p.Receiver.NetworkAddress, out NetworkAdapter localAdapter))
            {
                localAdapter.EnqueuePacket(p);
            }
            else
            {
                List <byte> request = new List <byte>();
                request.Add(( byte )NetworkNodeRequestType.SEND);
                byte[] data = p.Serialize();
                request.AddRange(BitConverter.GetBytes(data.Length));
                request.AddRange(data);

                lock ( m_Client )
                {
                    m_Client.GetStream().Write(request.ToArray(), 0, request.Count);
                }
            }
        }