예제 #1
0
 public void RunBeforeEveryTest()
 {
     _utility = new NetworkUtilities();
     _testConnectionServer = new TcpConnectionServer(_utility.GetLocalIPAddress(), 8080);
     _testScheduler        = new CommandScheduler();
     _testServer           = new EditorConnectionServer(_testConnectionServer, _testScheduler, 15000);
 }
예제 #2
0
        public void RunBeforeEveryTest()
        {
            var networkUtilities = new NetworkUtilities();

            _localIpAddress = networkUtilities.GetLocalIPAddress();
            _server         = new TcpConnectionServer(_localIpAddress, 15845);
        }
예제 #3
0
 public void ConnectHost(string username, JeffistanceMessageProcessor messageProcessor)
 {
     username  = string.IsNullOrWhiteSpace(username) ? DEFAULT_HOST_NAME : username;
     Host.Name = username;
     Host.Connect(NetworkUtilities.GetLocalIPAddress(), Connection.PORT_NO);
     Host.AttachMessageHandler(new MessageHandler(messageProcessor, Host.Connection));
     Host.GreetServer();
 }
예제 #4
0
        public void RunBeforeEveryTest()
        {
            var networkUtilities = new NetworkUtilities();

            _localIpAddress = networkUtilities.GetLocalIPAddress();
            _server         = new TcpConnectionServer(_localIpAddress, 15845);
            _testClient     = Substitute.For <IConnectionClient>();
        }
예제 #5
0
        public void RunBeforeEveryTest()
        {
            var networkUtilities = new NetworkUtilities();

            _localIpAddress = networkUtilities.GetLocalIPAddress();
            _testPort       = 15987;
            _testListener   = new TcpConnectionServer(_localIpAddress, _testPort);
            _testListener.StartServer();
        }
예제 #6
0
    private void Install()
    {
        var service          = new NetworkUtilities();
        var scheduler        = new CommandScheduler();
        var serverConnection = new TcpConnectionServer(service.GetLocalIPAddress(), ServerPort);

        _server         = new EditorConnectionServer(serverConnection, scheduler, BroadcastPort);
        ServerText.text = string.Format("Server running on {0}", serverConnection.Adress + ":" + serverConnection.Port.ToString());
    }
예제 #7
0
        public void Run(int port)
        {
            Connection     = new ServerConnection(port);
            MessageHandler = new MessageHandler(new ServerMessageProcessor(this), Connection);
            ObservableUserList.CollectionChanged += OnUserListChanged;
            Connection.OnDisconnection           += OnUserDisconnect;
            Connection.OnMessageReceived         += MessageHandler.OnMessageReceived;
            Connection.Run();
            var ip = NetworkUtilities.GetLocalIPAddress();

            _logger.LogInformation($"Started server on {ip}:{port}");
        }
예제 #8
0
        public void TestConnection()
        {
            server.Run();
            var client = new ClientConnection(NetworkUtilities.GetLocalIPAddress(), DEFAULT_PORT);

            while (true)
            {
                if (server.Clients.Count > 0)
                {
                    break;
                }
            }
            Assert.IsTrue(server.Clients.Count > 0);
            // FIXME vvvvv THIS SHOULD WORK ^^^^^^^ THIS SHOULDN'T
            // Assert.That(server.Clients.Count, Is.GreaterThan(0).After(5).Seconds.PollEvery(500).MilliSeconds);
        }
예제 #9
0
 public Host(int port = DEFAULT_PORT, string username = "******", bool dedicated = false) : base(username)
 {
     IsHost = true;
     Server = new ServerConnection(port);
     Perms  = new Permissions
     {
         CanKick = true
     };
     Server.OnMessageReceived += OnMessageReceived;
     Server.OnConnection      += OnConnection;
     Server.Run();
     if (!dedicated)
     {
         Connect(NetworkUtilities.GetLocalIPAddress(), port);
     }
 }
예제 #10
0
        public IEnumerator ServerShouldBroadcastIpAndPortAfterStart()
        {
            var testReceiver = new UdpBroadcastReceiver(15000);

            testReceiver.StartReceiveBroadcast();
            _testServer.StartServer();
            var called = false;

            testReceiver.BroadcastDataReceived += data =>
            {
                called = true;
                Assert.AreEqual(_utility.GetLocalIPAddress() + ":8080", data);
            };
            _testScheduler.Tick();
            yield return(new WaitForSeconds(0.5f));

            Assert.IsTrue(called);
            testReceiver.StopReceiveBroadcast();
        }
예제 #11
0
        public void TestDisconnectClient()
        {
            server.Run();
            var client = new ClientConnection(NetworkUtilities.GetLocalIPAddress(), DEFAULT_PORT);

            while (true)
            {
                if (server.Clients.Count > 0)
                {
                    break;
                }
            }

            foreach (ClientConnection c in server.Clients.ToArray())
            {
                server.Kick(c);
            }

            Assert.IsTrue(server.Clients.Count == 0);
        }
예제 #12
0
 public TcpInboundServerConfiguration()
 {
     IPAddress = NetworkUtilities.GetLocalIPAddress();
     Port      = 8801;
 }
 public TcpOutboundClientConfiguration()
 {
     IPAddress = NetworkUtilities.GetLocalIPAddress();
     Port      = 9901;
 }