// [Test] public void SimpleConnectionToServerTest() { var client = new OHSWebSocketClient("localhost", freePort); client.Connect(); client.WaitForConnectionId(); client.PlayerLogin("TestName"); string playerId = client.PlayerInfo.Id; HashSet <Type> waitingForTypes = new HashSet <Type>(); waitingForTypes.Add(typeof(AddArmyEvent)); waitingForTypes.Add(typeof(AddArmyEvent)); waitingForTypes.Add(typeof(TerrainLayer)); for (int i = 3; i > 0; i--) { var testEvent = client.Events.Take(); if (waitingForTypes.Contains(testEvent.GetType())) { waitingForTypes.Remove(testEvent.GetType()); } } if (waitingForTypes.Count > 0) { Assert.Fail("Not All Events Are Valid"); } client.Disconnect(); client = new OHSWebSocketClient("localhost", freePort); client.Connect(); client.WaitForConnectionId(); client.PlayerLogin("TestName", playerId); }
public void Setup() { byte[,] map = { { 1, 1, 1, 3, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 3, 1, 1, 1 } }; freePort = GetFreePortHelper.NextFreePort(4649); var basicServer = BasicServer.CreateInstance(freePort); basicServer.RunAsynch(new ByteArrayMapLoader(map)); Thread.Sleep(2000); _client = new OHSWebSocketClient("localhost", freePort); _client.Connect(); _client.WaitForConnectionId(); _client.PlayerLogin("TestName"); playerId = _client.PlayerInfo.Id; }