public void StartNetworkClient(string roomCode) { client = gameObject.AddComponent <NetworkClient>(); NetworkSync sync = gameObject.AddComponent <NetworkSync>(); sync.Initialize(0, "GameController"); client.Initialize(); matchmakingClient = GetComponent <MatchmakingClient>() ?? gameObject.AddComponent <MatchmakingClient>(); matchmakingClient.JoinRoom = roomCode; }
private void OnApplicationQuit() { if (GameClient != null) { GameClient.Disconnect(); } if (MatchmakingClient != null) { MatchmakingClient.Disconnect(); } }
// Best practice: try to delete your tickets if you end up in a bad state and don't plan to retry // This sends a fire-and-forget ticket deletion request void CleanUpTicket(string ticketId) { if (string.IsNullOrEmpty(ticketId)) { return; } var url = MatchmakingClient.BuildMatchmakingServiceUrl(m_MatchmakingServiceUrl); var delOp = MatchmakingClient.DeleteTicketAsync(url, ticketId); delOp.completed += asyncOp => { var request = ((UnityWebRequestAsyncOperation)asyncOp).webRequest; request.Dispose(); }; }
public static void Reconnect() { switch (instance.build) { case BuildTypes.Cloud: MatchmakingClient = new MatchmakingClient( instance.port, instance.server, instance.gameName ); break; case BuildTypes.Local: MatchmakingClient = new LocalMatchmakingClient(); break; } }
public void CleanupNetwork() { if (IsHost) { Destroy(host); host = null; Destroy(matchmakingHost); matchmakingHost = null; } else { Destroy(client); client = null; Destroy(matchmakingClient); matchmakingClient = null; } Destroy(GetComponent <NetworkSync>()); IsHost = false; }
public NetworkClient() { this.matchmakingClient = new MatchmakingClient(); }
private void InitializeRealClients() { MatchmakingClient = new MatchmakingClient(port, server, gameName); GameClient = new GameClient(); }