private void OnDisable() { SteamGameServer.EnableHeartbeats(false); SteamGameServer.LogOff(); GameServer.Shutdown(); Debug.Log("Shutdown."); }
public Tetrominous_Server() { if (!SteamGameServer.InitGameServer(0, TETROMINOUS_SERVER_PORT, TETROMINOUS_MASTER_SERVER_UPDATER_PORT, 0, Game1.APPID, TETROMINOUS_SERVER_VERSION)) { Console.WriteLine("Failed to Initiate Game Server."); } // 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(GAMEDIR); // These fields are currently required, but will go away soon. // See their documentation for more info SteamGameServer.SetProduct("Tetronimous"); SteamGameServer.SetGameDescription("Tetris minigames"); // Initiate Anonymous login 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 SteamGameServer.EnableHeartbeats(true); }
public void Shutdown() { SteamGameServer.EnableHeartbeats(false); SteamGameServer.LogOff(); GameServer.Shutdown(); Debug.Log("Shutdown."); }
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; }
private void OnDisable() { if (!m_bInitialized) { return; } // Notify Steam master server we are going offline #if USE_GS_AUTH_API SteamGameServer.EnableHeartbeats(false); #endif m_CallbackSteamServersConnected.Dispose(); // Disconnect from the steam servers SteamGameServer.LogOff(); // release our reference to the steam client library GameServer.Shutdown(); m_bInitialized = false; Debug.Log("Shutdown."); }
public void LogOff() { if (initialized && SteamGameServer.BLoggedOn()) { SteamGameServer.EnableHeartbeats(false); SteamGameServer.LogOff(); } }
// Token: 0x06001835 RID: 6197 RVA: 0x000890AC File Offset: 0x000874AC public void close() { if (!this.isHosting) { return; } SteamGameServer.EnableHeartbeats(false); SteamGameServer.LogOff(); GameServer.Shutdown(); this.isHosting = false; }
private void ServerConnectedCallback(SteamServersConnected_t callback) { Debug.Log("[Steamworks.NET] GameServer connected successfully"); SteamGameServer.SetServerName(ServerConfig.ServerName); SteamGameServer.SetPasswordProtected(!string.IsNullOrEmpty(ServerConfig.Password)); SteamGameServer.SetMaxPlayerCount(ServerConfig.TeamNum * ServerConfig.NumPerTeam); SteamGameServer.SetMapName(ServerConfig.MapName); SteamGameServer.SetDedicatedServer(true); SetAdditionalGameInfo(); SteamGameServer.EnableHeartbeats(true); }
public override void Close() { if (!IsHosting) { return; } SteamGameServer.EnableHeartbeats(false); SteamGameServer.LogOff(); GameServer.Shutdown(); SteamAPI.Shutdown(); IsHosting = false; }
public void SetUpdate() { if (!SteamDSConfig.initialized) { return; } GameServer.RunCallbacks(); if (SteamDSConfig.connectedToSteam) { this.SendUpdatedServerDetailsToSteam(); } SteamGameServer.EnableHeartbeats(true); }
private void OnDisable() { // Notify Steam master server we are going offline #if USE_GS_AUTH_API SteamGameServer.EnableHeartbeats(false); #endif // Disconnect from the steam servers SteamGameServer.LogOff(); // release our reference to the steam client library GameServer.Shutdown(); Debug.Log("Shutdown."); }
private static void P2PSessionRequest(P2PSessionRequest_t param) { SteamGameServer.EnableHeartbeats(true); Debug.Log("CoopSteamServer.P2PSessionRequest (host): remoteId=" + param.m_steamIDRemote); SteamGameServerNetworking.AcceptP2PSessionWithUser(param.m_steamIDRemote); P2PSessionState_t p2PSessionState_t; if (SteamGameServerNetworking.GetP2PSessionState(param.m_steamIDRemote, out p2PSessionState_t)) { Debug.Log("P2P Session with " + param.m_steamIDRemote + " accepted"); } else { Debug.Log("P2P Session with " + param.m_steamIDRemote + " failed"); } }
// 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; }
public static bool RegisterServer_modded(string name, bool password, string version, bool publicServer, string worldName, ZSteamMatchmaking __instance) { __instance.UnregisterServer(); SteamGameServer.SetServerName(config.ServerName); SteamGameServer.SetMapName(config.SteamMapName); SteamGameServer.SetPasswordProtected(password); SteamGameServer.SetGameTags(version); SteamGameServer.EnableHeartbeats(publicServer); SteamGameServer.SetMaxPlayerCount(config.Size); SteamGameServer.SetGameDescription("Valheim"); AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerServerName").SetValue(__instance, config.ServerName); AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerPassword").SetValue(__instance, password); AccessTools.Field(typeof(ZSteamMatchmaking), "m_registerVerson").SetValue(__instance, version); print("Registering lobby (modded)"); return(false); }
public static bool Start(Action connected, Action failed) { CoopSteamServer.Connected = connected; CoopSteamServer.Failed = failed; CoopSteamServer.Initialize(); if (GameServer.Init(0u, 8766, 27015, 27016, EServerMode.eServerModeNoAuthentication, "0.11.3.0.0")) { Debug.Log("started steam server"); SteamGameServer.EnableHeartbeats(true); SteamGameServer.SetProduct("The Forest"); SteamGameServer.SetGameDescription("The Forest Game Description"); SteamGameServer.LogOnAnonymous(); return(true); } Debug.LogError("Could not start SteamGameServer"); CoopSteamServer.Shutdown(); return(false); }
private void Start() { if (!SteamDSConfig.isDedicatedServer && !SteamManager.Initialized) { SteamManager.Reset(); } SteamDSConfig.MapName = GameSetup.Difficulty.ToString(); SteamDSConfig.manager.SetStart(this.loadAsync); bool flag = GameServer.Init(0u, SteamDSConfig.ServerSteamPort, SteamDSConfig.ServerGamePort, SteamDSConfig.ServerQueryPort, SteamDSConfig.ServerAuthMode, SteamDSConfig.ServerVersion); if (flag) { Debug.Log("GameServer init success. Port: " + SteamDSConfig.ServerGamePort); if (CoopDedicatedServerStarter.< > f__mg$cache0 == null) { CoopDedicatedServerStarter.< > f__mg$cache0 = new SteamAPIWarningMessageHook_t(CoopDedicatedServerStarter.SteamAPIDebugTextHook); } SteamGameServerUtils.SetWarningMessageHook(CoopDedicatedServerStarter.< > f__mg$cache0); SteamGameServer.SetModDir("theforestDS"); SteamGameServer.SetProduct(SteamDSConfig.ProductName); SteamGameServer.SetGameDescription(SteamDSConfig.ProductDescription); SteamGameServer.SetServerName(SteamDSConfig.ServerName); SteamGameServer.SetDedicatedServer(true); if (string.IsNullOrEmpty(SteamDSConfig.ServerSteamAccount)) { Debug.Log("Set a LogOnAnonymous"); SteamGameServer.LogOnAnonymous(); } else { Debug.Log("Set a Logon"); SteamGameServer.LogOn(SteamDSConfig.ServerSteamAccount); } SteamGameServer.EnableHeartbeats(true); SteamDSConfig.initialized = true; } else { Debug.LogError("GameServer.InitSafe failed"); CoopDedicatedServerStarter.ShutDown(); } }
// 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; }
// 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"); }
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."); }
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."); }