public addToAuditList ( string content ) : void | ||
content | string | |
Результат | void |
private void msgHandler(byte[] buffer, int bufferLength, bool audit) { string msg = System.Text.Encoding.UTF8.GetString(buffer, 0, bufferLength).Replace("\\", "\\\\").Trim(); if (msg == string.Empty) { return; } if (audit) { auditWindow.addToAuditList(msg); } else { this.Dispatcher.Invoke(new Action(() => sendDanmaku(msg))); } }
private void networkListenLoop(int _port, bool audit) { Console.WriteLine("Network thread is starting.. Listen on:" + GlobalVariable._user_com_port.ToString()); networkSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint ip = new IPEndPoint(IPAddress.Loopback, _port); networkSocket.Bind(ip); byte[] buf = new byte[102400]; int bufLength; EndPoint remote = new IPEndPoint(IPAddress.Any, 0); while (true) { try { bufLength = networkSocket.ReceiveFrom(buf, ref remote); Console.WriteLine(buf.Length); string msg = System.Text.Encoding.UTF8.GetString(buf, 0, bufLength).Replace("\\", "\\\\").Trim(); if (msg == string.Empty) { return; } if (audit) { auditWindow.addToAuditList(msg); } else { this.Dispatcher.Invoke(new Action(() => engine.DrawDanmaku(msg))); } } catch (ThreadAbortException) { Console.WriteLine("Communication Thread is shutting down.."); } catch (Exception e) { Console.WriteLine("Unknown Exception: \r\n" + e.ToString()); } } }