private static bool ConnectToSteam() { if (!Steamworks.Load(true)) { ShowError("Steamworks failed to load."); return(false); } _steamClient012 = Steamworks.CreateInterface <ISteamClient012>(); if (_steamClient012 == null) { ShowError("Failed to create Steam Client inferface."); return(false); } int pipe = _steamClient012.CreateSteamPipe(); if (pipe == 0) { ShowError("Failed to create Steam pipe."); return(false); } int user = _steamClient012.ConnectToGlobalUser(pipe); if (user == 0) { ShowError("Failed to connect to Steam user."); return(false); } _steamApps001 = _steamClient012.GetISteamApps <ISteamApps001>(user, pipe); if (_steamApps001 == null) { ShowError("Failed to create Steam Apps inferface."); return(false); } return(true); }
public Steam() { _log = LogManager.GetLogger(this); _log.Info("Steam initializing..."); if (!Steamworks.Load()) { _log.Error("Failed to load Steamworks."); throw new SteamException("Failed to load Steamworks"); } _log.Debug("Creating SteamClient012 interface..."); SteamClient012 = Steamworks.CreateInterface <ISteamClient012>(); if (SteamClient012 == null) { _log.Error("Failed to create SteamClient012 interface"); throw new SteamException("Failed to create SteamClient012 interface"); } _log.Debug("Creating steam pipe and connecting to global user..."); _pipe = SteamClient012.CreateSteamPipe(); if (_pipe == 0) { _log.Error("Failed to create Steam pipe"); throw new SteamException("Failed to create Steam pipe"); } _user = SteamClient012.ConnectToGlobalUser(_pipe); if (_user == 0) { _log.Error("Failed to connect user"); throw new SteamException("Failed to connect to global user"); } _log.Debug("Getting SteamUtils005 interface..."); SteamUtils005 = SteamClient012.GetISteamUtils <ISteamUtils005>(_pipe); if (SteamUtils005 == null) { _log.Error("Failed to obtain Steam utils"); throw new SteamException("Failed to obtain Steam utils"); } _log.Debug("Getting SteamUser016 interface..."); SteamUser016 = SteamClient012.GetISteamUser <ISteamUser016>(_user, _pipe); if (SteamUser016 == null) { _log.Error("Failed to obtain Steam user interface"); throw new SteamException("Failed to obtain Steam user interface"); } _log.Debug("Getting SteamFriends002 interface..."); SteamFriends002 = SteamClient012.GetISteamFriends <ISteamFriends002>(_user, _pipe); if (SteamFriends002 == null) { _log.Error("Failed to obtain Steam friends (002)"); throw new SteamException("Failed to obtain Steam friends (002)"); } _log.Debug("Getting SteamFriends014 interface..."); SteamFriends014 = SteamClient012.GetISteamFriends <ISteamFriends014>(_user, _pipe); if (SteamFriends014 == null) { _log.Error("Failed to obtain Steam friends (013)"); throw new SteamException("Failed to obtain Steam friends (013)"); } SteamApps001 = SteamClient012.GetISteamApps <ISteamApps001>(_user, _pipe); if (SteamApps001 == null) { _log.Error("Failed to obtain SteamApps006"); throw new SteamException("Failed to obtain SteamApps006"); } SteamApps006 = SteamClient012.GetISteamApps <ISteamApps006>(_user, _pipe); if (SteamApps006 == null) { _log.Error("Failed to obtain Steam apps (006)"); throw new SteamException("Failed to obtain Steam apps (006)"); } SteamInstallPath = Steamworks.GetInstallPath(); SteamConfigPath = Path.Combine(SteamInstallPath, "config", "config.vdf"); _log.DebugFormat("Steam installed at {0}, config at {1}", SteamInstallPath, SteamConfigPath); // Set up callbacks _log.Debug("Setting up Steam callbacks..."); _personaStateChange = new Callback <PersonaStateChange_t>(HandlePersonaStateChange); _friendProfileInfoResponse = new Callback <FriendProfileInfoResponse_t>(HandleFriendProfileInfoResponse); _friendAdded = new Callback <FriendAdded_t>(HandleFriendAdded); _friendChatMessage = new Callback <FriendChatMsg_t>(HandleFriendChatMessage); _appEventStateChange = new Callback <AppEventStateChange_t>(HandleAppEventStateChange); LocalUser = new LocalUser(this); Friends = new Friends(this); Apps = new Apps(this); // Spawn dispatch thread CallbackDispatcher.SpawnDispatchThread(_pipe); }