private void HandleJoinGameMsg(InsightMessage _insightMsg) { var message = (JoinGameMsg)_insightMsg.message; Debug.Log($"[GameMasterManager] - Received player requesting join the game : {message.gameUniqueId}"); var game = registeredGameServers.Find(_e => _e.uniqueId == message.gameUniqueId); Assert.IsNotNull(game); if (game.currentPlayers < game.maxPlayers) { Assert.IsTrue(registeredPlayers.Exists(_e => _e.uniqueId == message.uniqueId)); playersInGame.Add(message.uniqueId, message.gameUniqueId); var changeServerMsg = new ChangeServerMsg { uniqueId = game.uniqueId, networkAddress = game.networkAddress, networkPort = game.networkPort }; var responseToSend = new InsightNetworkMessage(changeServerMsg) { callbackId = _insightMsg.callbackId, status = CallbackStatus.Success }; if (_insightMsg is InsightNetworkMessage netMsg) { server.NetworkReply(netMsg.connectionId, responseToSend); } else { server.InternalReply(responseToSend); } } else { var responseToSend = new InsightNetworkMessage(new ChangeServerMsg()) { callbackId = _insightMsg.callbackId, status = CallbackStatus.Error }; if (_insightMsg is InsightNetworkMessage netMsg) { server.NetworkReply(netMsg.connectionId, responseToSend); } else { server.InternalReply(responseToSend); } } }
void HandleChangeServersMsg(InsightNetworkMessage netMsg) { ChangeServerMsg message = netMsg.ReadMessage <ChangeServerMsg>(); if (client.logNetworkMessages) { Debug.Log("[InsightClient] - Connecting to GameServer: " + message.NetworkAddress + ":" + message.NetworkPort + "/" + message.SceneName); } networkManager.networkAddress = message.NetworkAddress; networkManagerTelepathyTransport.port = message.NetworkPort; SceneManager.LoadScene(message.SceneName); networkManager.StartClient(); }
void HandleChangeServersMsg(InsightNetworkMessage netMsg) { ChangeServerMsg message = netMsg.ReadMessage <ChangeServerMsg>(); logger.Log("[InsightClient] - Connecting to GameServer: " + message.NetworkAddress + ":" + message.NetworkPort + "/" + message.SceneName); if (networkManagerTransport.GetType().GetField("port") != null) { networkManagerTransport.GetType().GetField("port").SetValue(networkManagerTransport, message.NetworkPort); } //For IgnoranceTransport if (networkManagerTransport.GetType().GetField("CommunicationPort") != null) { networkManagerTransport.GetType().GetField("CommunicationPort").SetValue(networkManagerTransport, message.NetworkPort); } NetworkManager.singleton.networkAddress = message.NetworkAddress; SceneManager.LoadScene(message.SceneName); NetworkManager.singleton.StartClient(); }
void HandleChangeServersMsg(InsightNetworkMessage netMsg) { ChangeServerMsg message = netMsg.ReadMessage <ChangeServerMsg>(); Debug.Log("[InsightClient] - Connecting to GameServer: " + message.NetworkAddress + ":" + message.NetworkPort + "/" + message.SceneName); if (networkManagerTransport is MultiplexTransport) { ushort startPort = message.NetworkPort; foreach (Transport transport in (networkManagerTransport as MultiplexTransport).transports) { SetPort(transport, startPort++); } } else { SetPort(networkManagerTransport, message.NetworkPort); } NetworkManager.singleton.networkAddress = message.NetworkAddress; NetworkManager.singleton.StartClient(); SceneManager.LoadScene(message.SceneName); }