Esempio n. 1
0
        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!");
            }
        }
Esempio n. 2
0
        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;
            }
        }