/// <summary> /// Initialize the steam client. /// If <paramref name="asyncCallbacks"/> is false you need to call <see cref="RunCallbacks"/> manually every frame. /// </summary> public static bool Init(uint appid, bool asyncCallbacks = true, bool isDevelopment = false) { if (initialized) { return(true); } System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString()); System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString()); developmentBuild = isDevelopment; if (!SteamAPI.Init()) { return(false); } AppId = appid; initialized = true; // // Dispatch is responsible for pumping the // event loop. // Dispatch.Init(); Dispatch.ClientPipe = SteamAPI.GetHSteamPipe(); AddInterface <SteamApps>(); AddInterface <SteamFriends>(); AddInterface <SteamInput>(); AddInterface <SteamInventory>(); AddInterface <SteamMatchmaking>(); AddInterface <SteamMatchmakingServers>(); AddInterface <SteamMusic>(); AddInterface <SteamNetworking>(); AddInterface <SteamNetworkingSockets>(); AddInterface <SteamNetworkingUtils>(); AddInterface <SteamParental>(); AddInterface <SteamParties>(); AddInterface <SteamRemoteStorage>(); AddInterface <SteamScreenshots>(); AddInterface <SteamUGC>(); AddInterface <SteamUser>(); AddInterface <SteamUserStats>(); AddInterface <SteamUtils>(); AddInterface <SteamVideo>(); AddInterface <SteamRemotePlay>(); if (asyncCallbacks) { // // This will keep looping in the background every 16 ms // until we shut down. // Dispatch.LoopClientAsync(); } return(true); }
/// <summary> /// Initialize the steam client. /// If asyncCallbacks is false you need to call RunCallbacks manually every frame. /// </summary> public static void Init(uint appid, bool asyncCallbacks = true) { if (initialized) { throw new System.Exception("Calling SteamClient.Init but is already initialized"); } System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString()); System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString()); if (!SteamAPI.Init()) { throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId."); } AppId = appid; initialized = true; // // Dispatch is responsible for pumping the // event loop. // Dispatch.Init(); Dispatch.ClientPipe = SteamAPI.GetHSteamPipe(); AddInterface <SteamApps>(); AddInterface <SteamFriends>(); AddInterface <SteamInput>(); AddInterface <SteamInventory>(); AddInterface <SteamMatchmaking>(); AddInterface <SteamMatchmakingServers>(); AddInterface <SteamMusic>(); AddInterface <SteamNetworking>(); AddInterface <SteamNetworkingSockets>(); AddInterface <SteamNetworkingUtils>(); AddInterface <SteamParental>(); AddInterface <SteamParties>(); AddInterface <SteamRemoteStorage>(); AddInterface <SteamScreenshots>(); AddInterface <SteamUGC>(); AddInterface <SteamUser>(); AddInterface <SteamUserStats>(); AddInterface <SteamUtils>(); AddInterface <SteamVideo>(); AddInterface <SteamRemotePlay>(); AddInterface <SteamHTMLSurface>(); if (asyncCallbacks) { // // This will keep looping in the background every 16 ms // until we shut down. // Dispatch.LoopClientAsync(); } }
/// <summary> /// Initialize the steam server. /// If <paramref name="asyncCallbacks"/> is <see langword="false"/> you need to call <see cref="RunCallbacks"/> manually every frame. /// </summary> public static void Init(AppId appid, SteamServerInit init, bool asyncCallbacks = true) { if (IsValid) { throw new System.Exception("Calling SteamServer.Init but is already initialized"); } uint ipaddress = 0; // Any Port if (init.IpAddress != null) { ipaddress = Utility.IpToInt32(init.IpAddress); } System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString()); System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString()); var secure = (int)(init.Secure ? 3 : 2); // // Get other interfaces // if (!SteamInternal.GameServer_Init(ipaddress, 0, init.GamePort, init.QueryPort, secure, init.VersionString)) { throw new System.Exception($"InitGameServer returned false ({ipaddress},{0},{init.GamePort},{init.QueryPort},{secure},\"{init.VersionString}\")"); } // // Dispatch is responsible for pumping the // event loop. // Dispatch.Init(); Dispatch.ServerPipe = SteamGameServer.GetHSteamPipe(); AddInterface <SteamServer>(); AddInterface <SteamUtils>(); AddInterface <SteamNetworking>(); AddInterface <SteamServerStats>(); //AddInterface<ISteamHTTP>(); AddInterface <SteamInventory>(); AddInterface <SteamUGC>(); AddInterface <SteamApps>(); AddInterface <SteamNetworkingUtils>(); AddInterface <SteamNetworkingSockets>(); // // Initial settings // AdvertiseServer = true; MaxPlayers = 32; BotCount = 0; Product = $"{appid.Value}"; ModDir = init.ModDir; GameDescription = init.GameDescription; Passworded = false; DedicatedServer = init.DedicatedServer; if (asyncCallbacks) { // // This will keep looping in the background every 16 ms // until we shut down. // Dispatch.LoopServerAsync(); } }
/// <summary> /// Initialize the steam server. /// If asyncCallbacks is false you need to call RunCallbacks manually every frame. /// </summary> public static void Init(AppId appid, SteamServerInit init, bool asyncCallbacks = true) { uint ipaddress = 0; // Any Port if (init.SteamPort == 0) { init = init.WithRandomSteamPort(); } if (init.IpAddress != null) { ipaddress = Utility.IpToInt32(init.IpAddress); } System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString()); System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString()); var secure = (int)(init.Secure ? 3 : 2); // // Get other interfaces // if (!SteamInternal.GameServer_Init(ipaddress, init.SteamPort, init.GamePort, init.QueryPort, secure, init.VersionString)) { throw new System.Exception($"InitGameServer returned false ({ipaddress},{init.SteamPort},{init.GamePort},{init.QueryPort},{secure},\"{init.VersionString}\")"); } // // Dispatch is responsible for pumping the // event loop. // Dispatch.Init(); Dispatch.ServerPipe = SteamGameServer.GetHSteamPipe(); Console.WriteLine($"Dispatch.ServerPipe = {Dispatch.ServerPipe.Value}"); AddInterface <SteamServer>(); AddInterface <SteamNetworkingUtils>(); AddInterface <SteamNetworkingSockets>(); // // Initial settings // AutomaticHeartbeats = true; MaxPlayers = 32; BotCount = 0; Product = $"{appid.Value}"; ModDir = init.ModDir; GameDescription = init.GameDescription; Passworded = false; DedicatedServer = init.DedicatedServer; InstallEvents(); if (asyncCallbacks) { // // This will keep looping in the background every 16 ms // until we shut down. // Dispatch.LoopServerAsync(); } }