Exemplo n.º 1
0
        public static LobbyWindow lanGame(UserAccount account, ILobbyGUI gui)
        {
            DiscoveryClient dc = new DiscoveryClient(new UdpDiscoveryEndpoint());
            FindCriteria fc = new FindCriteria(typeof(IDiscoveryTest));
            fc.Duration = TimeSpan.FromSeconds(5);
            FindResponse fr = dc.Find(fc);

            if (fr.Endpoints.Count > 0)
            {
                ip = fr.Endpoints[0].Address.Uri.Host.ToString();
            }
            else
            {
                string HostName = System.Net.Dns.GetHostName();
                System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostByName(HostName);
                string IpAdresse = hostInfo.AddressList[0].ToString();
                ip = IpAdresse;
                Server server = new Server(new WCFTCPServiceFactory(),ip);
                server.run();
            }

            factory = new WCFTCPConnectionFactory();
            lobbyWindow = new LobbyWindow(account, gui, factory);
            factory.connectToLobby(ip, lobbyWindow);

            return lobbyWindow;
        }
Exemplo n.º 2
0
 public void sendMessageTest()
 {
     Server server = new Server(new WCFTCPServiceFactory(),"localhost");
     server.run();
     TestGUI testGui = new TestGUI();
     testGui.sendMessage("TestMsg");
     Assert.AreEqual(1, testGui.logUpdated);
     Assert.AreEqual(1, testGui.messageUpdated);
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            string HostName = System.Net.Dns.GetHostName();
            System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostByName(HostName);
            string IpAdresse = hostInfo.AddressList[0].ToString();

            Server.Server server = new Server.Server(new WCFTCPServiceFactory(),IpAdresse);
            server.run();
            Console.WriteLine("Server up and running");
            Console.WriteLine("Press \"any key\" to stop");
            Console.ReadKey();
        }
Exemplo n.º 4
0
 public void runTest()
 {
     //Debugger.Launch();
     Server server = new Server(new WCFHTTPServiceFactory(),"localhost");
     server.run(); // TODO: Initialize to an appropriate value
     server.createGame("TestGame",new SimpleGameStrategy(1)); // TODO: Initialize to an appropriate value
     IGameGUI gameGUI = new TestGUI(server);
     gameGUI.eventShipPlacement();
     List<ShipPosition> positions = new List<ShipPosition>();
     List<Field> fields = new List<Field>();
     fields.Add(new Field(1,2));
     positions.Add(new ShipPosition(new Ship(new Shape(1)),fields));
     gameGUI.shipPlacement(positions);
     gameGUI.eventTurn();
     gameGUI.shoot(new UserAccount("TestUser",0),new Field(1,2));
 }
Exemplo n.º 5
0
 public TestGUI(Server server)
 {
     UserAccount owner = new UserAccount("TestUser", 0);
     String connString = server.joinGame("TestGame");
     Assert.AreEqual("http://localhost/Game/TestGame", connString);
     WCFConnectionFactory factory = new WCFTCPConnectionFactory();
     gameWindow = new GameWindow(owner, connString, this,factory);
 }
Exemplo n.º 6
0
 public Lobby(BattleShipServer.Server.Server server)
 {
     this.server = server;
 }