/// <summary> /// 初始化udp /// </summary> public void Connect() { udpClient = new UdpClient(PortUtils.GetNewPort()); UdpState s = new UdpState(); s.e = e; s.u = udpClient; udpClient.BeginReceive(new AsyncCallback(ReceiveBuffer), s); EventSystem.RegisterEvent(EventID.send_udp_buffer, SendBuffer); EventSystem.RegisterEvent(EventID.receive_udp_buffer, ReceiveUdpBuffer); //去初始udp EventSystem.DispatchEvent(EventID.udp_init_success); }