상속: UInt64Handle
예제 #1
0
파일: Callbacks.cs 프로젝트: Kolpa/SteamKit
			internal ScreenshotAddedCallback( JobID jobID, CMsgClientUCMAddScreenshotResponse msg )
			{
				JobID = jobID;

				Result = ( EResult )msg.eresult;
				ScreenshotID = msg.screenshotid;
			}
예제 #2
0
            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;
            }
예제 #4
0
			internal OfflineMessageCallback(JobID jobID, CMsgClientOfflineMessageNotification msg) {
				JobID = jobID;

				if (msg == null) {
					return;
				}

				OfflineMessages = msg.offline_messages;
				Users = msg.friends_with_offline_messages;
			}
예제 #5
0
            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;
            }
예제 #6
0
            internal PlayingSessionStateCallback(JobID jobID, CMsgClientPlayingSessionState msg)
            {
                if ((jobID == null) || (msg == null))
                {
                    throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
                }

                JobID = jobID;
                PlayingBlocked = msg.playing_blocked;
            }
예제 #7
0
			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 };
				}
			}
예제 #8
0
        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;
        }
예제 #9
0
			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));
				}
			}
예제 #10
0
        /// <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();
        }
예제 #11
0
        /// <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 );
            
        }
예제 #12
0
			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));
			}
예제 #13
0
			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)
					};
				}
			}
예제 #14
0
            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;
            }
예제 #15
0
            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;
            }
예제 #16
0
        /// <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 );
            }
        }
예제 #17
0
        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);
        }
예제 #18
0
        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);
        }
예제 #19
0
        public static bool TryRemoveJob(JobID jobID)
        {
            JobAction job;

            return TryRemoveJob(jobID, out job);
        }
예제 #20
0
            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;
            }
예제 #21
0
            internal IgnoreFriendCallback( JobID jobID, MsgClientSetIgnoreFriendResponse response )
            {
                this.JobID = jobID;

                this.Result = response.Result;
            }
예제 #22
0
            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,
                };
            }
예제 #23
0
파일: Bot.cs 프로젝트: tkphoto/SteamBot
        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);
        }
예제 #24
0
        /// <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;
        }
예제 #25
0
        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);
        }
예제 #26
0
        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);
        }
예제 #27
0
            internal WebAPIUserNonceCallback( JobID jobID, CMsgClientRequestWebAPIAuthenticateUserNonceResponse body )
            {
                this.JobID = jobID;

                this.Result = ( EResult )body.eresult;
                this.Nonce = body.webapi_authenticate_user_nonce;
            }
예제 #28
0
 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() );
            }
예제 #30
0
파일: Program.cs 프로젝트: JustHev/SteamKit
        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!" );
        }