Exemplo n.º 1
0
        public void ServerStart()
        {
            //---------------------------------------------------------------------
            //Setup
            //---------------------------------------------------------------------
            TCP_Config config;

            config.address = "127.0.0.1";
            config.port    = 4451;

            ServerLibrary.Server server = new ServerLibrary.Server();
            ServerLibrary.ServerConnectionTCP connection = new ServerLibrary.ServerConnectionTCP("Tester");
            ServerListenerTCP listener = new ServerListenerTCP(config);

            connection.AddListener(listener);
            server.AddConnection(connection);

            //---------------------------------------------------------------------
            //Run Test
            //---------------------------------------------------------------------
            server.Start();

            //---------------------------------------------------------------------
            //Gather Output
            //---------------------------------------------------------------------

            //---------------------------------------------------------------------
            //Assert
            //---------------------------------------------------------------------
        }
Exemplo n.º 2
0
        public void SendUdpToClient()
        {
            //---------------------------------------------------------------------
            //Setup
            //---------------------------------------------------------------------
            UDP_Config config;

            config.address = "127.0.0.1";
            config.port    = 4440;

            ServerLibrary.Server server = new ServerLibrary.Server();
            ServerLibrary.ServerConnectionUDP connection = new ServerLibrary.ServerConnectionUDP("TesterUdpClient");
            ServerListenerUDP listener = new ServerListenerUDP(config);

            connection.AddListener(listener);
            server.AddConnection(connection);
            server.Start();

            ChatMessagePacket packet = new ChatMessagePacket("Hello", "Tester");

            //---------------------------------------------------------------------
            //Run Test
            //---------------------------------------------------------------------
            server.SendPacketToClient(packet, "TesterUdpClient", "Bob");

            //---------------------------------------------------------------------
            //Gather Output
            //---------------------------------------------------------------------


            //---------------------------------------------------------------------
            //Assert
            //---------------------------------------------------------------------
        }
        public void ServerCollectionOfPackets()
        {
            //---------------------------------------------------------------------
            //Setup
            //---------------------------------------------------------------------
            TCP_Config config;

            config.address = "127.0.0.1";
            config.port    = 4450;

            ServerLibrary.Server server = new ServerLibrary.Server();
            ServerLibrary.ServerConnectionTCP connection = new ServerLibrary.ServerConnectionTCP("Tester");
            ServerListenerTCP listener = new ServerListenerTCP(config);

            connection.AddListener(listener);
            server.AddConnection(connection);
            server.Start();

            List <Packet> expecetedPackets = new List <Packet>();

            //---------------------------------------------------------------------
            //Run Test
            //---------------------------------------------------------------------
            List <Packet> packets = server.RecieveMessages("Tester");

            //---------------------------------------------------------------------
            //Gather Output
            //---------------------------------------------------------------------

            //---------------------------------------------------------------------
            //Assert
            //---------------------------------------------------------------------
            Assert.AreEqual(expecetedPackets, packets);
        }
Exemplo n.º 4
0
        public void ServerSendTcpToAll()
        {
            //---------------------------------------------------------------------
            //Setup
            //---------------------------------------------------------------------
            TCP_Config config;

            config.address = "127.0.0.1";
            config.port    = 4447;

            ServerLibrary.Server server = new ServerLibrary.Server();
            ServerLibrary.ServerConnectionTCP connection = new ServerLibrary.ServerConnectionTCP("Tester");
            ServerListenerTCP listener = new ServerListenerTCP(config);

            connection.AddListener(listener);
            server.AddConnection(connection);
            server.Start();

            ChatMessagePacket packet = new ChatMessagePacket("Hello", "Tester");

            //---------------------------------------------------------------------
            //Run Test
            //---------------------------------------------------------------------
            server.SendPacketToAll(packet, "Tester");

            //---------------------------------------------------------------------
            //Gather Output
            //---------------------------------------------------------------------


            //---------------------------------------------------------------------
            //Assert
            //---------------------------------------------------------------------
        }