Ejemplo n.º 1
0
 /// <summary>
 /// constructor </summary>
 /// <param name='localPort'>The local port to bind to directly on the instanciation, you can specify a port from 1 to 65535, 0  will bind to the first available port, -1 will not bind (you will have to call Bind method manually after instanciation then). Default is -1.</param><c>!Any other value will throw an exception!</c>
 public UDPServer(int localPort = -1)
 {
     _udpManager = new UDPManager(-1);
     _udpManager._udpServerPeers = new List <UDPPeer>();
     _udpManager._InitHiddenChannels();
     _udpManager.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RECEIVED, _ReceivedDataHandler);
     _udpManager.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, _CancelHandler);
     _udpManager.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, _RetryHandler);
     _udpManager.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, _DeliveryHandler);
     _udpManager.AddEventListener <UDPClassicMessageEvent>(UDPClassicMessageEvent.Names.MESSAGE, _ClassicDataSystemHandler);
     this._udpManager.AddEventListener <UDPManagerEvent>(UDPManagerEvent.Names.BOUND, this._Listening);
     if (localPort > -1)
     {
         this.Start(localPort);
     }
 }