internal ScreenshotAddedCallback( JobID jobID, CMsgClientUCMAddScreenshotResponse msg ) { JobID = jobID; Result = ( EResult )msg.eresult; ScreenshotID = msg.screenshotid; }
internal QueryCallback( JobID jobID, CMsgGMSClientServerQueryResponse msg ) { JobID = jobID; var serverList = msg.servers .Select( s => new Server( s ) ) .ToList(); this.Servers = new ReadOnlyCollection<Server>( serverList ); }
internal ResponseCallback( JobID jobID, CMsgClientRequestAccountDataResponse msg ) { this.JobID = jobID; Result = ( EResult )msg.eresult; Action = ( ERequestAccountData )msg.action; CountMatches = msg.ct_matches; AccountName = msg.account_name; }
internal OfflineMessageCallback(JobID jobID, CMsgClientOfflineMessageNotification msg) { JobID = jobID; if (msg == null) { return; } OfflineMessages = msg.offline_messages; Users = msg.friends_with_offline_messages; }
internal FindOrCreateLeaderboardCallback( JobID jobID, CMsgClientLBSFindOrCreateLBResponse resp ) { this.JobID = jobID; this.Result = ( EResult )resp.eresult; this.ID = resp.leaderboard_id; this.EntryCount = resp.leaderboard_entry_count; this.SortMethod = ( ELeaderboardSortMethod )resp.leaderboard_sort_method; this.DisplayType = ( ELeaderboardDisplayType )resp.leaderboard_display_type; }
internal PlayingSessionStateCallback(JobID jobID, CMsgClientPlayingSessionState msg) { if ((jobID == null) || (msg == null)) { throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); } JobID = jobID; PlayingBlocked = msg.playing_blocked; }
internal NotificationsCallback(JobID jobID, CMsgClientItemAnnouncements msg) { if ((jobID == null) || (msg == null)) { throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); } JobID = jobID; if (msg.count_new_items > 0) { Notifications = new HashSet<ENotification> { ENotification.Items }; } }
public static bool TryRemoveJob(JobID jobID, out JobAction job) { if (Jobs.TryRemove(jobID, out job)) { Log.WriteDebug("Job Manager", "Removed job: {0} ({1} jobs left)", jobID, Jobs.Count); return true; } return false; }
internal NotificationsCallback(JobID jobID, CMsgClientUserNotifications msg) { JobID = jobID; if (msg == null || msg.notifications == null) { return; } Notifications = new List<Notification>(msg.notifications.Count); foreach (var notification in msg.notifications) { Notifications.Add(new Notification((Notification.ENotificationType) notification.user_notification_type)); } }
/// <summary> /// Extends the lifetime of a job. /// </summary> /// <param name="jobId">The job identifier.</param> public void HeartbeatJob( JobID jobId ) { AsyncJob asyncJob = GetJob( jobId ); if ( asyncJob == null ) { // ignore heartbeats for jobs we're not tracking return; } asyncJob.Heartbeat(); }
/// <summary> /// Marks a certain job as remotely failed. /// </summary> /// <param name="jobId">The job identifier.</param> public void FailJob( JobID jobId ) { AsyncJob asyncJob = GetJob( jobId, andRemove: true ); if ( asyncJob == null ) { // ignore remote failures for jobs we're not tracking return; } asyncJob.SetFailed( dueToRemoteFailure: true ); }
internal NotificationsCallback(JobID jobID, CMsgClientUserNotifications msg) { if ((jobID == null) || (msg == null)) { throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); } JobID = jobID; if (msg.notifications.Count == 0) { return; } Notifications = new HashSet<ENotification>(msg.notifications.Select(notification => (ENotification) notification.user_notification_type)); }
internal NotificationsCallback(JobID jobID, CMsgClientItemAnnouncements msg) { JobID = jobID; if (msg == null) { return; } if (msg.count_new_items > 0) { Notifications = new List<Notification>(1) { new Notification(Notification.ENotificationType.Items) }; } }
internal UGCDetailsCallback( JobID jobID, CMsgClientUFSGetUGCDetailsResponse msg ) { JobID = jobID; Result = ( EResult )msg.eresult; AppID = msg.app_id; Creator = msg.steamid_creator; URL = msg.url; FileName = msg.filename; FileSize = msg.file_size; }
internal PublishedFilesCallback( JobID jobID, CMsgCREEnumeratePublishedFilesResponse msg ) { this.JobID = jobID; this.Result = ( EResult )msg.eresult; var fileList = msg.published_files .Select( f => new File( f ) ) .ToList(); this.Files = new ReadOnlyCollection<File>( fileList ); this.TotalResults = ( int )msg.total_results; }
/// <summary> /// Passes a callback to a pending async job. /// If the given callback completes the job, the job is removed from this manager. /// </summary> /// <param name="jobId">The JobID.</param> /// <param name="callback">The callback.</param> public void TryCompleteJob( JobID jobId, CallbackMsg callback ) { AsyncJob asyncJob = GetJob( jobId ); if ( asyncJob == null ) { // not a job we are tracking ourselves, can ignore it return; } // pass this callback into the job so it can determine if the job is finished (in the case of multiple responses to a job) bool jobFinished = asyncJob.AddResult( callback ); if ( jobFinished ) { // if the job is finished, we can stop tracking it asyncJobs.TryRemove( jobId, out asyncJob ); } }
public void PostedCallbackTriggersActionForExplicitJobIDInvalid() { var jobID = new JobID(123456); var callback = new CallbackForTest { JobID = jobID, UniqueID = Guid.NewGuid() }; var didCall = false; Action<CallbackForTest> action = delegate(CallbackForTest cb) { Assert.Equal(callback.UniqueID, cb.UniqueID); Assert.Equal(jobID, cb.JobID); didCall = true; }; using (new Callback<CallbackForTest>(action, mgr, JobID.Invalid)) { PostAndRunCallback(callback); } Assert.True(didCall); }
public void PostedJobCallbackTriggersAction() { var callback = new CallbackForTest { UniqueID = Guid.NewGuid() }; var jobID = new JobID(123456); var jobCallback = new SteamClient.JobCallback<CallbackForTest>(jobID, callback); var didCall = false; Action<CallbackForTest, JobID> action = delegate(CallbackForTest cb, JobID jid) { Assert.Equal(cb.UniqueID, callback.UniqueID); Assert.Equal(jobID, jid); didCall = true; }; using (new JobCallback<CallbackForTest>(action, mgr)) { PostAndRunCallback(jobCallback); } Assert.True(didCall); }
public static bool TryRemoveJob(JobID jobID) { JobAction job; return TryRemoveJob(jobID, out job); }
internal ProfileInfoCallback( JobID jobID, CMsgClientFriendProfileInfoResponse response ) { JobID = jobID; Result = ( EResult )response.eresult; SteamID = response.steamid_friend; TimeCreated = DateUtils.DateTimeFromUnixTime( response.time_created ); RealName = response.real_name; CityName = response.city_name; StateName = response.state_name; CountryName = response.country_name; Headline = response.headline; Summary = response.summary; }
internal IgnoreFriendCallback( JobID jobID, MsgClientSetIgnoreFriendResponse response ) { this.JobID = jobID; this.Result = response.Result; }
internal UpdateMachineAuthCallback( JobID jobID, CMsgClientUpdateMachineAuth msg ) { JobID = jobID; Data = msg.bytes; BytesToWrite = ( int )msg.cubtowrite; Offset = ( int )msg.offset; FileName = msg.filename; OneTimePassword = new OTPDetails { Type = msg.otp_type, Identifier = msg.otp_identifier, SharedSecret = msg.otp_sharedsecret, TimeDrift = msg.otp_timedrift, }; }
void OnUpdateMachineAuthCallback(SteamUser.UpdateMachineAuthCallback machineAuth, JobID jobId) { byte[] hash = SHAHash (machineAuth.Data); File.WriteAllBytes (String.Format ("{0}.sentryfile", logOnDetails.Username), machineAuth.Data); var authResponse = new SteamUser.MachineAuthDetails { BytesWritten = machineAuth.BytesToWrite, FileName = machineAuth.FileName, FileSize = machineAuth.BytesToWrite, Offset = machineAuth.Offset, SentryFileHash = hash, // should be the sha1 hash of the sentry file we just wrote OneTimePassword = machineAuth.OneTimePassword, // not sure on this one yet, since we've had no examples of steam using OTPs LastError = 0, // result from win32 GetLastError Result = EResult.OK, // if everything went okay, otherwise ~who knows~ JobID = jobId, // so we respond to the correct server job }; // send off our response SteamUser.SendMachineAuthResponse (authResponse); }
/// <summary> /// Retrieves a job from this manager, and optionally removes it from tracking. /// </summary> /// <param name="jobId">The JobID.</param> /// <param name="andRemove">If set to <c>true</c>, this job is removed from tracking.</param> /// <returns></returns> AsyncJob GetJob( JobID jobId, bool andRemove = false ) { AsyncJob asyncJob; bool foundJob = false; if ( andRemove ) { foundJob = asyncJobs.TryRemove( jobId, out asyncJob ); } else { foundJob = asyncJobs.TryGetValue( jobId, out asyncJob ); } if ( !foundJob ) { // requested a job we're not tracking return null; } return asyncJob; }
public void PostedCallbackWithJobIDTriggersActionWhenNoJobIDSpecified() { var jobID = new JobID(123456); var callback = new CallbackForTest { JobID = jobID, UniqueID = Guid.NewGuid() }; var didCall = false; Action<CallbackForTest> action = delegate(CallbackForTest cb) { Assert.Equal(callback.UniqueID, cb.UniqueID); Assert.Equal(jobID, cb.JobID); didCall = true; }; using (new Callback<CallbackForTest>(action, mgr)) { PostAndRunCallback(callback); } Assert.True(didCall); }
public void PostedCallbackDoesNotTriggerActionForWrongJobID() { var jobID = new JobID(123456); var callback = new CallbackForTest { JobID = jobID, UniqueID = Guid.NewGuid() }; var didCall = false; Action<CallbackForTest> action = delegate(CallbackForTest cb) { didCall = true; }; using (new Callback<CallbackForTest>(action, mgr, new JobID(123))) { PostAndRunCallback(callback); } Assert.False(didCall); }
internal WebAPIUserNonceCallback( JobID jobID, CMsgClientRequestWebAPIAuthenticateUserNonceResponse body ) { this.JobID = jobID; this.Result = ( EResult )body.eresult; this.Nonce = body.webapi_authenticate_user_nonce; }
internal NumberOfPlayersCallback( JobID jobID, MsgClientGetNumberOfCurrentPlayersResponse resp ) { this.JobID = jobID; this.Result = resp.Result; this.NumPlayers = resp.NumPlayers; }
internal SteamLevelsCallback( JobID jobID, CMsgClientFSGetFriendsSteamLevelsResponse resp ) { this.JobID = jobID; Friends = new ReadOnlyCollection<Friend>( resp.friends.Select( f => new Friend( f ) ).ToList() ); }
static void OnMachineAuth( SteamUser.UpdateMachineAuthCallback callback, JobID jobId ) { Console.WriteLine( "Updating sentryfile..." ); byte[] sentryHash = CryptoHelper.SHAHash( callback.Data ); // write out our sentry file // ideally we'd want to write to the filename specified in the callback // but then this sample would require more code to find the correct sentry file to read during logon // for the sake of simplicity, we'll just use "sentry.bin" File.WriteAllBytes( "sentry.bin", callback.Data ); // inform the steam servers that we're accepting this sentry file steamUser.SendMachineAuthResponse( new SteamUser.MachineAuthDetails { JobID = jobId, FileName = callback.FileName, BytesWritten = callback.BytesToWrite, FileSize = callback.Data.Length, Offset = callback.Offset, Result = EResult.OK, LastError = 0, OneTimePassword = callback.OneTimePassword, SentryFileHash = sentryHash, } ); Console.WriteLine( "Done!" ); }