public void Init(FakeServerConnectionsComponent connHolder) { //Debug.Log("ServerLobbyComponent::Init Called"); connectionsComponent = connHolder; serverLobbySend = GetComponent <FakeServerLobbySend>(); serverLobbyDataComponent = GetComponent <FakeServerLobbyDataComponent>(); }
public IEnumerator LobbyClientSendsHeartBeatAndIDToServer() { // Assuming the path of the test scene SceneManager.LoadScene("Assets/Tests/PlayModeTests/TestScenes/TestLobbyClient.unity"); // Wait one frame for the scene to load yield return(null); ClientConnectionsComponent clientConn = GameObject.Find("ClientConnectionObject").GetComponent <ClientConnectionsComponent>(); FakeServerConnectionsComponent fakeServer = GameObject.Find("FakeServerConnectionsObject").GetComponent <FakeServerConnectionsComponent>(); //clientConn.Init(false, "127.0.0.1"); clientConn.SetIP("127.0.0.1"); clientConn.PrepareClient("LobbyScene"); fakeServer.PrepareServer("LobbyScene"); yield return(null); // ListAllGameObjectsInScene(); FakeServerLobbyDataComponent fakeServerData = GameObject.Find("FakeServerLobbyObject(Clone)").GetComponent <FakeServerLobbyDataComponent>(); List <byte> heartbeatRequest = new List <byte>(); heartbeatRequest.Add((byte)LOBBY_CLIENT_REQUESTS.HEARTBEAT); List <byte> heartbeatResponse = new List <byte>(); heartbeatResponse.Add((byte)LOBBY_SERVER_COMMANDS.HEARTBEAT); List <byte> getIdRequest = new List <byte>(); getIdRequest.Add((byte)LOBBY_CLIENT_REQUESTS.GET_ID); List <byte> getIdResponse = new List <byte>(); getIdResponse.Add((byte)LOBBY_SERVER_COMMANDS.SET_ID); getIdResponse.Add((byte)1); fakeServerData.SetResponse(heartbeatRequest, heartbeatResponse); fakeServerData.SetResponse(getIdRequest, getIdResponse); //Time.timeScale = 20.0f; Time.timeScale = 1.0f; float time = 0; while (time < 10) { time += Time.fixedDeltaTime; yield return(new WaitForFixedUpdate()); } Time.timeScale = 1.0f; Assert.AreEqual(1, fakeServer.GetConnections().Length); Assert.GreaterOrEqual(1, fakeServerData.GetResponseNumTimesCalled(heartbeatRequest)); Assert.AreEqual(1, fakeServerData.GetResponseNumTimesCalled(getIdRequest)); }
// Start is called before the first frame update private void Start() { // Initialize send queues for all possible players individualSendQueues = new List <Queue <byte> >(CONSTANTS.MAX_NUM_PLAYERS); for (int i = 0; i < CONSTANTS.MAX_NUM_PLAYERS; ++i) { individualSendQueues.Add(new Queue <byte>()); } allSendQueue = new Queue <byte>(); serverLobbyData = GetComponent <FakeServerLobbyDataComponent>(); }