public override void ServerStart() { if (!SteamManager.Initialized) { Debug.LogError("SteamWorks not initialized. Server could not be started."); return; } FetchSteamID(); if (ClientActive()) { Debug.LogError("Transport already running as client!"); return; } if (!ServerActive()) { Debug.Log("Starting server."); SteamGameServerNetworking.AllowP2PPacketRelay(AllowSteamRelay); server = Server.CreateServer(this, NetworkManager.singleton.maxConnections); activeNode = server; } else { Debug.LogError("Server already started!"); } }
public override void ClientConnect(string address) { if (!SteamManager.Initialized) { Debug.LogError("SteamWorks not initialized. Client could not be started."); OnClientDisconnected.Invoke(); return; } FetchSteamID(); if (ServerActive()) { Debug.LogError("Transport already running as server!"); return; } if (!ClientActive() || client.Error) { Debug.Log($"Starting client, target address {address}."); SteamGameServerNetworking.AllowP2PPacketRelay(AllowSteamRelay); client = Client.CreateClient(this, address); activeNode = client; } else { Debug.LogError("Client already running!"); } }
public override void ServerStart() { try { #if UNITY_SERVER SteamGameServerNetworkingUtils.InitRelayNetworkAccess(); #else SteamNetworkingUtils.InitRelayNetworkAccess(); #endif InitRelayNetworkAccess(); if (ClientActive()) { Debug.LogError("Transport already running as client!"); return; } if (!ServerActive()) { if (UseNextGenSteamNetworking) { Debug.Log($"Starting server [SteamSockets]."); server = NextServer.CreateServer(this, NetworkManager.singleton.maxConnections); } else { Debug.Log($"Starting server [DEPRECATED SteamNetworking]. Relay enabled: {AllowSteamRelay}"); #if UNITY_SERVER SteamGameServerNetworking.AllowP2PPacketRelay(AllowSteamRelay); #else SteamNetworking.AllowP2PPacketRelay(AllowSteamRelay); #endif server = LegacyServer.CreateServer(this, NetworkManager.singleton.maxConnections); } } else { Debug.LogError("Server already started!"); } } catch (Exception ex) { Debug.LogException(ex); return; } }