コード例 #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
            //---------------------------------------------------------------------
        }
コード例 #2
0
        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);
        }
コード例 #3
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
            //---------------------------------------------------------------------
        }
コード例 #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
            //---------------------------------------------------------------------
        }
コード例 #5
0
        public void ServerConstructor()
        {
            //---------------------------------------------------------------------
            //Setup
            //---------------------------------------------------------------------
            ServerLibrary.Server server;

            //---------------------------------------------------------------------
            //Run Test
            //---------------------------------------------------------------------
            server = new ServerLibrary.Server();

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

            //---------------------------------------------------------------------
            //Assert
            //---------------------------------------------------------------------
            Assert.IsNotNull(server);
        }
コード例 #6
0
        public void ServerAddConnection()
        {
            //---------------------------------------------------------------------
            //Setup
            //---------------------------------------------------------------------
            ServerLibrary.Server server = new ServerLibrary.Server();
            ServerLibrary.ServerConnectionUDP connection = new ServerLibrary.ServerConnectionUDP("Tester");

            //---------------------------------------------------------------------
            //Run Test
            //---------------------------------------------------------------------
            server.AddConnection(connection);

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

            //---------------------------------------------------------------------
            //Assert
            //---------------------------------------------------------------------
            Assert.IsNotNull(packets);
        }