示例#1
0
        public override void Open(string bindip, ushort port, bool lan)
        {
            if (bindip == "*")
            {
                bindip = "0.0.0.0";
            }
            if (IsHosting)
            {
                return;
            }
            var         ip   = SteamworksCommon.GetUInt32FromIp(bindip);
            EServerMode mode = EServerMode.eServerModeAuthenticationAndSecure;

            //if(lan) mode = EServerMode.eServerModeNoAuthentication;
            if (!GameServer.Init(ip, (ushort)(port + 2), port, (ushort)(port + 1), mode,
                                 GameInfo.VERSION))
            {
                throw new ServerInitializationFailedException("Couldn't start server (Steamworks API initialization failed)");
            }

            SteamGameServer.SetDedicatedServer(!lan);
            SteamGameServer.SetGameDescription(GameInfo.NAME);
            SteamGameServer.SetProduct(GameInfo.NAME);
            SteamGameServer.SetModDir(GameInfo.NAME);
            SteamGameServer.SetServerName(Description);
            SteamGameServer.LogOnAnonymous();
            SteamGameServer.SetPasswordProtected(false); //Todo
            SteamGameServer.EnableHeartbeats(true);

            Application.targetFrameRate = 60;
            IsHosting = true;
        }
        // Initialize SteamGameServer client and interface objects, and set server properties which may not be changed.
        //
        // After calling this function, you should set any additional server parameters, and then
        // call ISteamGameServer::LogOnAnonymous() or ISteamGameServer::LogOn()
        //
        // - unIP will usually be zero.  If you are on a machine with multiple IP addresses, you can pass a non-zero
        //   value here and the relevant sockets will be bound to that IP.  This can be used to ensure that
        //   the IP you desire is the one used in the server browser.
        // - usGamePort is the port that clients will connect to for gameplay.  You will usually open up your
        //   own socket bound to this port.
        // - usQueryPort is the port that will manage server browser related duties and info
        //		pings from clients.  If you pass STEAMGAMESERVER_QUERY_PORT_SHARED for usQueryPort, then it
        //		will use "GameSocketShare" mode, which means that the game is responsible for sending and receiving
        //		UDP packets for the master  server updater.  (See ISteamGameServer::HandleIncomingPacket and
        //		ISteamGameServer::GetNextOutgoingPacket.)
        // - The version string should be in the form x.x.x.x, and is used by the master server to detect when the
        //		server is out of date.  (Only servers with the latest version will be listed.)
        public static bool Init(uint unIP, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString)
        {
            InteropHelp.TestIfPlatformSupported();

            bool ret;

            using (var pchVersionString2 = new InteropHelp.UTF8StringHandle(pchVersionString)) {
                ret = NativeMethods.SteamInternal_GameServer_Init(unIP, 0, usGamePort, usQueryPort, eServerMode, pchVersionString2);
            }

            // Steamworks.NET specific: We initialize the SteamAPI Context like this for now, but we need to do it
            // every time that Unity reloads binaries, so we also check if the pointers are available and initialized
            // before each call to any interface functions. That is in InteropHelp.cs
            if (ret)
            {
                ret = CSteamGameServerAPIContext.Init();
            }

            if (ret)
            {
                CallbackDispatcher.Initialize();
            }

            return(ret);
        }
示例#3
0
 public static bool InitSafe(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString)
 {
     InteropHelp.TestIfPlatformSupported();
     bool result;
     using (InteropHelp.UTF8StringHandle uTF8StringHandle = new InteropHelp.UTF8StringHandle(pchVersionString))
     {
         result = NativeMethods.SteamGameServer_InitSafe(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, uTF8StringHandle);
     }
     return result;
 }
示例#4
0
    // Use this for initialization
    void Start()
    {
        SteamServersConnected = Callback <SteamServersConnected_t> .CreateGameServer(OnSteamServersConnected);

#if DISABLED
        SteamServersConnectedFailure = Callback <SteamServerConnectFailure_t> .CreateGameServer(OnSteamServersConnectFailure);

        SteamServerDisconnected = Callback <SteamServersDisconnected_t> .CreateGameServer(OnSteamServersDisconnected);

        CallbackPolicyResponse = Callback <GSPolicyResponse_t> .CreateGameServer(OnPolicyResponse);

        CallbackGSAuthTicketResponse = Callback <ValidateAuthTicketResponse_t> .CreateGameServer(OnValidateAuthTicketResponse);

        CallbackP2PSessionRequest = Callback <P2PSessionRequest_t> .CreateGameServer(OnP2PSessionRequest);

        CallbackP2PSessionConnectFail = Callback <P2PSessionConnectFail_t> .CreateGameServer(OnP2PSessionConnectFail);
#endif
        Initialized       = false;
        _connectedToSteam = false;
#if USE_GS_AUTH_API
        EServerMode eMode = EServerMode.eServerModeAuthenticationAndSecure;
#endif
        uint    unFlags    = 27016;
        AppId_t nGameAppId = new AppId_t();
        Initialized = SteamGameServer.InitGameServer(0, AUTHENTICATION_PORT, SERVER_PORT, unFlags, nGameAppId, SNAKES_SERVER_VERSION);
        if (Initialized == false)
        {
            return;
        }
        SteamGameServer.SetModDir("snakes");
        SteamGameServer.SetProduct("Steamworks Example");
        SteamGameServer.SetGameDescription("Steamworks Example");
        SteamGameServer.LogOnAnonymous();
        SteamGameServer.EnableHeartbeats(true);
        print("Started");



        //SteamNetworking
        // Pause everything until all clients are initialized
        Time.timeScale = 0;

        NetworkManager.Instance.serverMessageEvents[NetworkMessageType.NetworkBehaviour]            += OnMessageNetworkBehaviour;
        NetworkManager.Instance.serverMessageEvents[NetworkMessageType.NetworkBehaviourInitialized] += OnMessageNetworkBehaviourInitialized;
        NetworkManager.Instance.serverMessageEvents[NetworkMessageType.Initialization] += OnMessageInitialization;
        NetworkManager.Instance.serverMessageEvents[NetworkMessageType.PingPong]       += OnMessagePingPong;
    }
        // Token: 0x06001834 RID: 6196 RVA: 0x00088FEC File Offset: 0x000873EC
        public void open(uint ip, ushort port, ESecurityMode security)
        {
            if (this.isHosting)
            {
                return;
            }
            EServerMode eServerMode = EServerMode.eServerModeInvalid;

            if (security != ESecurityMode.LAN)
            {
                if (security != ESecurityMode.SECURE)
                {
                    if (security == ESecurityMode.INSECURE)
                    {
                        eServerMode = EServerMode.eServerModeAuthentication;
                    }
                }
                else
                {
                    eServerMode = EServerMode.eServerModeAuthenticationAndSecure;
                }
            }
            else
            {
                eServerMode = EServerMode.eServerModeNoAuthentication;
            }
            if (!GameServer.Init(ip, port + 2, port, port + 1, eServerMode, "1.0.0.0"))
            {
                throw new Exception("GameServer API initialization failed!");
            }
            SteamGameServer.SetDedicatedServer(this.appInfo.isDedicated);
            SteamGameServer.SetGameDescription(this.appInfo.name);
            SteamGameServer.SetProduct(this.appInfo.name);
            SteamGameServer.SetModDir(this.appInfo.name);
            SteamGameServer.LogOnAnonymous();
            SteamGameServer.EnableHeartbeats(true);
            this.isHosting = true;
        }
    // This should only ever get called on first load and after an Assembly reload, You should never Disable the Steamworks Manager yourself.
    private void OnEnable()
    {
        if (s_instance == null)
        {
            s_instance = this;
        }

        if (!m_bInitialized)
        {
            return;
        }

        if (m_SteamAPIWarningMessageHook == null)
        {
            // Set up our callback to recieve warning messages from Steam.
            // You must launch with "-debug_steamapi" in the launch args to recieve warnings.
            m_SteamAPIWarningMessageHook = new SteamAPIWarningMessageHook_t(SteamAPIDebugTextHook);
            SteamClient.SetWarningMessageHook(m_SteamAPIWarningMessageHook);
        }

        EServerMode eMode = EServerMode.eServerModeAuthenticationAndSecure;

        GameServer.Init(0, SPACEWAR_AUTHENTICATION_PORT, SPACEWAR_SERVER_PORT, SPACEWAR_MASTER_SERVER_UPDATER_PORT, eMode, SPACEWAR_SERVER_VERSION);
    }
示例#7
0
    // Use this for initialization
    void Start()
    {
        SteamServersConnected = Callback <SteamServersConnected_t> .CreateGameServer(OnSteamServersConnected);

#if DISABLED
        SteamServersConnectedFailure = Callback <SteamServerConnectFailure_t> .CreateGameServer(OnSteamServersConnectFailure);

        SteamServerDisconnected = Callback <SteamServersDisconnected_t> .CreateGameServer(OnSteamServersDisconnected);

        CallbackPolicyResponse = Callback <GSPolicyResponse_t> .CreateGameServer(OnPolicyResponse);

        CallbackGSAuthTicketResponse = Callback <ValidateAuthTicketResponse_t> .CreateGameServer(OnValidateAuthTicketResponse);

        CallbackP2PSessionRequest = Callback <P2PSessionRequest_t> .CreateGameServer(OnP2PSessionRequest);

        CallbackP2PSessionConnectFail = Callback <P2PSessionConnectFail_t> .CreateGameServer(OnP2PSessionConnectFail);
#endif
        Initialized       = false;
        _connectedToSteam = false;
#if USE_GS_AUTH_API
        EServerMode eMode = EServerMode.eServerModeAuthenticationAndSecure;
#endif
        uint    unFlags    = 27016;
        AppId_t nGameAppId = new AppId_t();
        Initialized = SteamGameServer.InitGameServer(0, AUTHENTICATION_PORT, SERVER_PORT, unFlags, nGameAppId, SNAKES_SERVER_VERSION);
        if (Initialized == false)
        {
            return;
        }
        SteamGameServer.SetModDir("snakes");
        SteamGameServer.SetProduct("Steamworks Example");
        SteamGameServer.SetGameDescription("Steamworks Example");
        SteamGameServer.LogOnAnonymous();
        SteamGameServer.EnableHeartbeats(true);
        print("Started");
    }
示例#8
0
 // [Steamworks.NET] This is for Ease of use, since we don't need to care about the differences between them in C#.
 public static bool Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString)
 {
     return(InitSafe(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString));
 }
    private void OnEnable()
    {
        m_CallbackSteamServersConnected = Callback <SteamServersConnected_t> .CreateGameServer(OnSteamServersConnected);

#if DISABLED
        m_CallbackSteamServersConnectFailure = Callback <SteamServerConnectFailure_t> .CreateGameServer(OnSteamServersConnectFailure);

        m_CallbackSteamServersDisconnected = Callback <SteamServersDisconnected_t> .CreateGameServer(OnSteamServersDisconnected);

        m_CallbackPolicyResponse = Callback <GSPolicyResponse_t> .CreateGameServer(OnPolicyResponse);

        m_CallbackGSAuthTicketResponse = Callback <ValidateAuthTicketResponse_t> .CreateGameServer(OnValidateAuthTicketResponse);

        m_CallbackP2PSessionRequest = Callback <P2PSessionRequest_t> .CreateGameServer(OnP2PSessionRequest);

        m_CallbackP2PSessionConnectFail = Callback <P2PSessionConnectFail_t> .CreateGameServer(OnP2PSessionConnectFail);
#endif

        m_bInitialized      = false;
        m_bConnectedToSteam = false;

#if USE_GS_AUTH_API
        EServerMode eMode = EServerMode.eServerModeAuthenticationAndSecure;
#else
        // Don't let Steam do authentication
        EServerMode eMode = EServerMode.eServerModeNoAuthentication;
#endif

        // Initialize the SteamGameServer interface, we tell it some info about us, and we request support
        // for both Authentication (making sure users own games) and secure mode, VAC running in our game
        // and kicking users who are VAC banned
        m_bInitialized = GameServer.Init(0, SPACEWAR_AUTHENTICATION_PORT, SPACEWAR_SERVER_PORT, SPACEWAR_MASTER_SERVER_UPDATER_PORT, eMode, SPACEWAR_SERVER_VERSION);
        if (!m_bInitialized)
        {
            Debug.Log("SteamGameServer_Init call failed");
            return;
        }
        print("Initialized");

        // Set the "game dir".
        // This is currently required for all games.  However, soon we will be
        // using the AppID for most purposes, and this string will only be needed
        // for mods.  it may not be changed after the server has logged on
        SteamGameServer.SetModDir("spacewar");

        // These fields are currently required, but will go away soon.
        // See their documentation for more info
        SteamGameServer.SetProduct("SteamworksExample");
        SteamGameServer.SetGameDescription("Steamworks Example");

        // We don't support specators in our game.
        // .... but if we did:
        //SteamGameServer.SetSpectatorPort( ... );
        //SteamGameServer.SetSpectatorServerName( ... );

        // Initiate Anonymous logon.
        // Coming soon: Logging into authenticated, persistent game server account
        SteamGameServer.LogOnAnonymous();

        // We want to actively update the master server with our presence so players can
        // find us via the steam matchmaking/server browser interfaces
#if USE_GS_AUTH_API
        SteamGameServer.EnableHeartbeats(true);
#endif

        Debug.Log("Started.");
    }
示例#10
0
		public static extern bool SteamInternal_GameServer_Init(uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, InteropHelp.UTF8StringHandle pchVersionString);
示例#11
0
 // Methods
 public static bool Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString) => default;         // 0x00000001807CD080-0x00000001807CD1D0
示例#12
0
        public GServer(IPAddress unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString)
        {
            _IpAddress = unIP;
            _Players = new Dictionary<CSteamID, EPlayerStatus>();

            m_CallbackSteamServersConnected = Callback<SteamServersConnected_t>.CreateGameServer(OnSteamServersConnected);
            m_CallbackSteamServersConnectFailure = Callback<SteamServerConnectFailure_t>.CreateGameServer(OnSteamServersConnectFailure);
            m_CallbackSteamServersDisconnected = Callback<SteamServersDisconnected_t>.CreateGameServer(OnSteamServersDisconnected);
            m_CallbackPolicyResponse = Callback<GSPolicyResponse_t>.CreateGameServer(OnPolicyResponse);

            m_CallbackGSAuthTicketResponse = Callback<ValidateAuthTicketResponse_t>.CreateGameServer(OnValidateAuthTicketResponse);
            m_CallbackP2PSessionRequest = Callback<P2PSessionRequest_t>.CreateGameServer(OnP2PSessionRequest);
            m_CallbackP2PSessionConnectFail = Callback<P2PSessionConnectFail_t>.CreateGameServer(OnP2PSessionConnectFail);

            _SteamPort = usSteamPort;
            _GamePort = usGamePort;
            _QueryPort = usQueryPort;
            _ServerMode = eServerMode;

            _Initalized = GameServer.Init(IPInteger, SteamPort, GamePort, QueryPort, ServerMode, VersionString);
            if (!_Initalized)
            {
                Debug.LogError("GameServer.Init failed and returned false.");
            }
        }
示例#13
0
    private void Start()
    {
        if (!Packsize.Test())
        {
            Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
        }
        if (!DllCheck.Test())
        {
            Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);
        }
        try
        {
            if (SteamAPI.RestartAppIfNecessary(SteamDSConfig.AppIdDS))
            {
                Application.Quit();
                return;
            }
        }
        catch (DllNotFoundException arg)
        {
            Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + arg, this);
            Application.Quit();
            return;
        }
        this.m_bInitialized = SteamAPI.Init();
        if (!this.m_bInitialized)
        {
            Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);
            return;
        }
        SteamConfig.BuildId = SteamApps.GetAppBuildId();
        string betaName;

        if (SteamApps.GetCurrentBetaName(out betaName, 50))
        {
            SteamConfig.BetaName = betaName;
        }
        Debug.Log("Steam Started");
        this.m_CallbackSteamServersConnected = Callback <SteamServersConnected_t> .CreateGameServer(new Callback <SteamServersConnected_t> .DispatchDelegate(this.OnSteamServersConnected));

        this.m_CallbackSteamServersConnectFailure = Callback <SteamServerConnectFailure_t> .CreateGameServer(new Callback <SteamServerConnectFailure_t> .DispatchDelegate(this.OnSteamServersConnectFailure));

        this.m_CallbackSteamServersDisconnected = Callback <SteamServersDisconnected_t> .CreateGameServer(new Callback <SteamServersDisconnected_t> .DispatchDelegate(this.OnSteamServersDisconnected));

        this.m_CallbackPolicyResponse = Callback <GSPolicyResponse_t> .CreateGameServer(new Callback <GSPolicyResponse_t> .DispatchDelegate(this.OnPolicyResponse));

        this.m_CallbackGSAuthTicketResponse = Callback <ValidateAuthTicketResponse_t> .CreateGameServer(new Callback <ValidateAuthTicketResponse_t> .DispatchDelegate(this.OnValidateAuthTicketResponse));

        this.m_CallbackP2PSessionRequest = Callback <P2PSessionRequest_t> .CreateGameServer(new Callback <P2PSessionRequest_t> .DispatchDelegate(this.OnP2PSessionRequest));

        this.m_CallbackP2PSessionConnectFail = Callback <P2PSessionConnectFail_t> .CreateGameServer(new Callback <P2PSessionConnectFail_t> .DispatchDelegate(this.OnP2PSessionConnectFail));

        this.m_bInitialized      = false;
        this.m_bConnectedToSteam = false;
        EServerMode eServerMode = EServerMode.eServerModeAuthenticationAndSecure;

        this.m_bInitialized = GameServer.Init(0u, SteamDSConfig.ServerSteamPort, SteamDSConfig.ServerGamePort, SteamDSConfig.ServerQueryPort, eServerMode, SteamDSConfig.ServerVersion);
        if (!this.m_bInitialized)
        {
            Debug.Log("SteamGameServer_Init call failed");
            return;
        }
        SteamGameServer.SetModDir("theforestDS");
        SteamGameServer.SetProduct("The Forest");
        SteamGameServer.SetGameDescription("The Forest Game Description");
        SteamGameServer.LogOnAnonymous();
        SteamGameServer.EnableHeartbeats(true);
        Debug.Log("Started.");
    }
示例#14
0
文件: Steam.cs 项目: sparker/Lemma
		// [Steamworks.NET] This is for Ease of use, since we don't need to care about the differences between them in C#.
		public static bool Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString) {
			InteropHelp.TestIfPlatformSupported();
			return NativeMethods.SteamGameServer_InitSafe(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
		}
        public static bool Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString)
        {
            InteropHelp.TestIfPlatformSupported();
            using (var pchVersionString2 = new InteropHelp.UTF8StringHandle(pchVersionString)) {
                return(NativeMethods.SteamGameServer_Init(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString2));

                `
            }
        }
示例#16
0
 // [Steamworks.NET] This is for Ease of use, since we don't need to care about the differences between them in C#.
 public static bool Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString)
 {
     InteropHelp.TestIfPlatformSupported();
     return(NativeMethods.SteamGameServer_InitSafe(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString));
 }
示例#17
0
        public bool Init(bool isDedicated, IPAddress ip, ushort port, ushort queryPort, ushort masterServerPort, ushort spectatorPort, EServerMode serverMode, string serverName, string spectatorServerName, string regionName, string gameName, string gameDescription, string gameVersion, string mapName, ushort maxClients, bool isPassworded, string modDir, OnGameServerClientApproved onGameServerClientApproved, OnGameServerClientDenied onGameServerClientDenied, OnGameServerClientKick onGameServerClientKick)
        {
            byte[] addressBytes = ip.GetAddressBytes();
            uint   ip1          = (uint)((int)addressBytes[0] << 24 | (int)addressBytes[1] << 16 | (int)addressBytes[2] << 8) | (uint)addressBytes[3];

            this._playersPendingAuth.Clear();
            this._playersConnected.Clear();
            this._botsConnected.Clear();
            this._onGameServerClientApproved = onGameServerClientApproved;
            this._onGameServerClientDenied   = onGameServerClientDenied;
            this._onGameServerClientKick     = onGameServerClientKick;
            if (this._internalOnGameServerClientApproved == null)
            {
                this._internalOnGameServerClientApproved = new OnGameServerClientApprovedBySteam(this.OnGameServerClientApprovedCallback);
                this._internalOnGameServerClientDenied   = new OnGameServerClientDeniedBySteam(this.OnGameServerClientDeniedCallback);
                this._internalOnGameServerClientKick     = new OnGameServerClientKickFromSteam(this.OnGameServerClientKickCallback);
                this._internalOnGameServerPolicyResponse = new OnGameServerPolicyResponseFromSteam(this.OnGameServerPolicyResponseCallback);
            }
            GameServer.SteamUnityAPI_SteamGameServer_SetCallbacks(Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnGameServerClientApproved), Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnGameServerClientDenied), Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnGameServerClientKick), Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnGameServerPolicyResponse));
            if (!GameServer.SteamUnityAPI_SteamGameServer_Init(ip1, masterServerPort, port, queryPort, serverMode, gameVersion))
            {
                return(false);
            }
            this._isInitialized       = true;
            this._gameServer          = GameServer.SteamUnityAPI_SteamGameServer();
            this._isDedicated         = isDedicated;
            this._serverName          = serverName;
            this._spectatorServerName = spectatorServerName;
            this._spectatorPort       = spectatorPort;
            this._mapName             = mapName;
            this._regionName          = regionName;
            this._gameName            = gameName;
            this._gameDescription     = gameDescription;
            this._maxClients          = maxClients;
            this._isPassworded        = isPassworded;
            this._modDir = modDir;
            this.SendBasicServerStatus();
            GameServer.SteamUnityAPI_SteamGameServer_LogOnAnonymous(this._gameServer);
            this.SendUpdatedServerStatus();
            return(true);
        }
示例#18
0
 public bool Init(bool isDedicated, IPAddress ip, ushort port, ushort queryPort, ushort masterServerPort, ushort spectatorPort, EServerMode serverMode, string serverName, string spectatorServerName, string regionName, string gameName, string gameDescription, string gameVersion, string mapName, ushort maxClients, bool isPassworded, OnGameServerClientApproved onGameServerClientApproved, OnGameServerClientDenied onGameServerClientDenied, OnGameServerClientKick onGameServerClientKick)
 {
     return(this.Init(isDedicated, ip, port, queryPort, masterServerPort, spectatorPort, serverMode, serverName, spectatorServerName, regionName, gameName, gameDescription, gameVersion, mapName, maxClients, isPassworded, string.Empty, onGameServerClientApproved, onGameServerClientDenied, onGameServerClientKick));
 }
示例#19
0
 private static bool SteamUnityAPI_SteamGameServer_Init(uint ip, ushort masterServerPort, ushort port, ushort queryPort, EServerMode serverMode, [MarshalAs(UnmanagedType.LPStr)] string gameVersion);
示例#20
0
        public static bool Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString)
        {
            InteropHelp.TestIfPlatformSupported();
            bool flag;

            using (InteropHelp.UTF8StringHandle pchVersionString2 = new InteropHelp.UTF8StringHandle(pchVersionString))
            {
                flag = NativeMethods.SteamGameServer_Init(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString2);
            }
            if (flag)
            {
                flag = CSteamGameServerAPIContext.Init();
            }
            if (flag)
            {
                CallbackDispatcher.Initialize();
            }
            return(flag);
        }
示例#21
0
 // [Steamworks.NET] This is for Ease of use, since we don't need to care about the differences between them in C#.
 public static bool Init(uint ip, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string versionString) => InitSafe(ip, usSteamPort, usGamePort, usQueryPort, eServerMode, versionString);
示例#22
0
		// Initialize ISteamGameServer interface object, and set server properties which may not be changed.
		//
		// After calling this function, you should set any additional server parameters, and then
		// call ISteamGameServer::LogOnAnonymous() or ISteamGameServer::LogOn()
		//
		// - usSteamPort is the local port used to communicate with the steam servers.
		// - usGamePort is the port that clients will connect to for gameplay.
		// - usQueryPort is the port that will manage server browser related duties and info
		//		pings from clients.  If you pass MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE for usQueryPort, then it
		//		will use "GameSocketShare" mode, which means that the game is responsible for sending and receiving
		//		UDP packets for the master  server updater. See references to GameSocketShare in isteamgameserver.h.
		// - The version string is usually in the form x.x.x.x, and is used by the master server to detect when the
		//		server is out of date.  (Only servers with the latest version will be listed.)
		public static bool Init(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString) {
			InteropHelp.TestIfPlatformSupported();
			using(var pchVersionString2 = new InteropHelp.UTF8StringHandle(pchVersionString)) {
				return NativeMethods.SteamGameServer_Init(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString2);
			}
		}
示例#23
0
        public static bool InitSafe(uint unIP, ushort usSteamPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString)
        {
            InteropHelp.TestIfPlatformSupported();
            bool result;

            using (InteropHelp.UTF8StringHandle uTF8StringHandle = new InteropHelp.UTF8StringHandle(pchVersionString))
            {
                result = NativeMethods.SteamGameServer_InitSafe(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, uTF8StringHandle);
            }
            return(result);
        }