Exemplo n.º 1
0
 public void QueuePacket(PacketInfo packetInfo)
 {
     lock (receiveLock)
     {
         received.Enqueue(packetInfo);
     }
 }
Exemplo n.º 2
0
        void Listen()
        {
            Debug.Log("thread start");
            client = new UdpClient(host.listenPort);
            client.Client.ReceiveTimeout = 3000;

            while (!end)
            {
                try
                {
                    IPEndPoint endpoint = null;
                    byte[]     bytes    = client.Receive(ref endpoint);

                    var packetInfo = new PacketInfo();
                    packetInfo.endPoint = endpoint;
                    packetInfo.data     = bytes;
                    host.QueuePacket(packetInfo);
                }
                catch (Exception e)
                {
                    //Debug.LogException(e);
                }
            }
            client.Close();
            Debug.Log("thread end");
        }