Ejemplo n.º 1
0
 public void CreateIPEndPointWithInvalidIPOrHost(string host)
 {
     if (host is null)
     {
         Assert.ThrowsAsync <ArgumentNullException>(() => LiteNetworkHelpers.CreateIpEndPointAsync(host, 4444));
     }
     else
     {
         Assert.ThrowsAsync <AggregateException>(() => LiteNetworkHelpers.CreateIpEndPointAsync(host, 4444));
     }
 }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public async void Start()
        {
            if (IsRunning)
            {
                throw new InvalidOperationException("Server is already running.");
            }

            OnBeforeStart();

            IPEndPoint localEndPoint = await LiteNetworkHelpers.CreateIpEndPointAsync(Options.Host, Options.Port).ConfigureAwait(false);

            _socket.Bind(localEndPoint);
            _socket.Listen(Options.Backlog);
            _acceptor.StartAccept();
            IsRunning = true;

            OnAfterStart();
        }
Ejemplo n.º 3
0
        public async void CreateValidIPEndPoint(string ipAddress, int port)
        {
            var ipEndPoint = await LiteNetworkHelpers.CreateIpEndPointAsync(ipAddress, port);

            Assert.NotNull(ipEndPoint);
        }
Ejemplo n.º 4
0
 public void CreateIPEndPointWithInvalidPort(int port)
 {
     Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => LiteNetworkHelpers.CreateIpEndPointAsync("127.0.0.1", port));
 }
Ejemplo n.º 5
0
 public void BuildUnspecifiedAddress(string ipOrHost)
 {
     Assert.ThrowsAsync <ArgumentException>(() => LiteNetworkHelpers.CreateIpEndPointAsync(ipOrHost, 4444));
 }