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; }
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); }
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(); }
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)); }