Beispiel #1
0
        /// <summary>
        /// 链接
        /// </summary>
        public void Connect()
        {
            lock (locker)
            {
                Disconnect();
                if (packer != null)
                {
                    packer.Clear();
                }

                udpConnector            = new UdpConnector();
                udpConnector.OnConnect += OnConnect;
                udpConnector.OnClose   += OnClose;
                udpConnector.OnError   += OnError;
                udpConnector.OnMessage += OnMessage;

                if (string.IsNullOrEmpty(host) || port < IPEndPoint.MinPort || port > IPEndPoint.MaxPort)
                {
                    udpConnector.Connect();
                }
                else
                {
                    udpConnector.Connect(host, port);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// 断开连接
 /// </summary>
 public void Disconnect()
 {
     if (udpConnector != null)
     {
         udpConnector.Dispose();
     }
     udpConnector = null;
 }
Beispiel #3
0
        /// <summary>
        /// 链接
        /// </summary>
        public void Connect()
        {
            Disconnect();
            if (packer != null) { packer.Clear(); }

            udpConnector = new UdpConnector();
            udpConnector.OnConnect += OnConnect;
            udpConnector.OnClose += OnClose;
            udpConnector.OnError += OnError;
            udpConnector.OnMessage += OnMessage;

            if (string.IsNullOrEmpty(host) || port < IPEndPoint.MinPort || port > IPEndPoint.MaxPort)
            {
                udpConnector.Connect();
            }
            else
            {
                udpConnector.Connect(host, port);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 断开连接
 /// </summary>
 public void Disconnect()
 {
     if (udpConnector != null)
     {
         udpConnector.Dispose();
     }
     udpConnector = null;
 }