Пример #1
0
 /// <summary>
 /// Start the server. Bind to the local port provided and start listening for connections</summary>
 /// <remarks>Only call this method if you did not provide a local port on the constructor parameter(or if you provide -1)</remarks>
 /// <c>If the server is already started (=Bound), the method will call Reset before starting again on the specified localPort</c>
 /// <param name='localPort'>The local port to bind to, you can specify a port from 1 to 65535, 0  will bind to the first available port. Default is 0.</param><c>!Any other value will throw an exception!</c>
 public void Start(int localPort)
 {
     if (_started)
     {
         Close(false);
     }
     _udpManager.Bind(localPort);
     _started = true;
 }
Пример #2
0
        // Start is called before the first frame update
        void Start()
        {
            udpm = new _UDPManager();
            udpm.DefaultTarget = this;

            //Add listeners on the instance of UDPManager
            udpm.On <UDPManagerEvent>(UDPManagerEvent.Names.BOUND, (UDPManagerEvent e) =>
            {
                listeners.OnBound?.Invoke(e);
            });
            udpm.On <UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, (UDPManagerEvent e) =>
            {
                listeners.OnDataCanceled?.Invoke(e);
            });
            udpm.On <UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, (UDPManagerEvent e) =>
            {
                listeners.OnDataDelivered?.Invoke(e);
            });
            udpm.On <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RECEIVED, (UDPManagerEvent e) =>
            {
                listeners.OnDataReceived?.Invoke(e);
            });
            udpm.On <UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, (UDPManagerEvent e) =>
            {
                listeners.OnDataRetried?.Invoke(e);
            });
            udpm.On <UDPManagerEvent>(UDPManagerEvent.Names.DATA_SENT, (UDPManagerEvent e) =>
            {
                listeners.OnDataSent?.Invoke(e);
            });

            channels.ForEach((UChannel uc) =>
            {
                udpm.AddChannel(uc.Name, uc.GuarantiesDelivery, uc.MaintainOrder, uc.RetryTime, uc.CancelTime);
            });

            udpm.Bind(port);
        }
Пример #3
0
 /// <summary>
 /// Bind to a local port </summary>
 /// <remarks>Only call this method if you did not provide a local port on the constructor parameter(or if you provide -1)</remarks>
 /// <c>If the instance is already bound, the method will call Reset before bounding again on the specified localPort</c>
 /// <param name='localPort'>The local port to bind to, you can specify a port from 1 to 65535, 0  will bind to the first available port. Default is 0.</param><c>!Any other value will throw an exception!</c>
 public void Bind(int localPort)
 {
     udpm.Bind(localPort);
 }