Пример #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);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 断开连接
 /// </summary>
 public void Disconnect()
 {
     if (udpConnector != null)
     {
         udpConnector.Dispose();
     }
     udpConnector = null;
 }
Пример #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);
            }
        }
Пример #4
0
 /// <summary>
 /// 断开连接
 /// </summary>
 public void Disconnect()
 {
     if (udpConnector != null)
     {
         udpConnector.Dispose();
     }
     udpConnector = null;
 }