void Update() { //byte byte[][] bytes = null; lock (binaryQueue) { bytes = binaryQueue.ToArray(); binaryQueue.Clear(); } if (handle != null) { foreach (var b in bytes) { handle.OnRawBytes(b); } } //string string[] messages = null; lock (messageQueue) { messages = messageQueue.ToArray(); messageQueue.Clear(); } if (handle != null) { foreach (var message in messages) { handle.OnRawString(message); } } }
void Update() { foreach (var packetInfo in udp.ReceiveAll()) { if (handle != null) { handle.OnRawBytes(packetInfo.data); handle.OnRawString(Encoding.UTF8.GetString(packetInfo.data)); } } if (!udp.isRunning && autoRestart) { udp.StartListener(); } }