public static NextServer CreateServer(FizzySteamworks transport, int maxConnections) { NextServer s = new NextServer(maxConnections); s.OnConnected += (id) => transport.OnServerConnected.Invoke(id); s.OnDisconnected += (id) => transport.OnServerDisconnected.Invoke(id); s.OnReceivedData += (id, data, ch) => transport.OnServerDataReceived.Invoke(id, new ArraySegment <byte>(data), ch); s.OnReceivedError += (id, exception) => transport.OnServerError.Invoke(id, exception); try { #if UNITY_SERVER SteamGameServerNetworkingUtils.InitRelayNetworkAccess(); #else SteamNetworkingUtils.InitRelayNetworkAccess(); #endif } catch (Exception ex) { Debug.LogException(ex); } s.Host(); return(s); }
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()) { if (UseNextGenSteamNetworking) { Debug.Log($"Starting server [SteamSockets]."); server = NextServer.CreateServer(this, NetworkManager.singleton.maxConnections); } else { Debug.Log($"Starting server [DEPRECATED SteamNetworking]. Relay enabled: {AllowSteamRelay}"); SteamNetworking.AllowP2PPacketRelay(AllowSteamRelay); server = LegacyServer.CreateServer(this, NetworkManager.singleton.maxConnections); } } else { Debug.LogError("Server already started!"); } }
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; } }
public static NextServer CreateServer(FizzyFacepunch transport, int maxConnections) { NextServer s = new NextServer(maxConnections); s.OnConnected += (id) => transport.OnServerConnected.Invoke(id); s.OnDisconnected += (id) => transport.OnServerDisconnected.Invoke(id); s.OnReceivedData += (id, data, ch) => transport.OnServerDataReceived.Invoke(id, new ArraySegment <byte>(data), ch); s.OnReceivedError += (id, exception) => transport.OnServerError.Invoke(id, exception); if (!SteamClient.IsValid) { Debug.LogError("SteamWorks not initialized."); } s.Host(); return(s); }