private static void ListenThread(object callee) { UDP_Receiver thiz = (UDP_Receiver)callee; while (true) { IPEndPoint remoteIP = null; byte[] data; if (thiz.m_udp.Available > 0) { data = thiz.m_udp.Receive(ref remoteIP); ReceiveDataType r = new ReceiveDataType(); r.data = Encoding.ASCII.GetString(data); r.remoteIP = remoteIP; thiz.m_receivedData.Enqueue(r); } // Sleepしないとフリーズする!? Thread.Sleep(1); } }
// Use this for initialization void Start() { m_udp = GetComponent <UDP_Receiver>(); m_udp.ReceiveHandler += OnReceive; InvokeRepeating("SendSearch", 1.0f, m_searchRate); }