/// <summary>
        /// Creates a new SteamChatHandler. Generates a random jQueryId to use.
        /// </summary>
        /// <param name="account">Account object of the account to use.</param>
        public SteamChatHandler(Account account)
        {
            _account = account;

            var rand = new Random();
            var jQueryId = (long)(((rand.NextDouble() * 2.0 - 1.0) * long.MaxValue) % 99999999999); //might be able to be larger, haven't checked
            if (jQueryId < 0) jQueryId = -jQueryId;
            _basejQuery = "jQuery" + jQueryId + _account.SteamId + "_{0}";

            _auth = Logon();
        }
        /// <summary>
        /// Creates a new SteamChatHandler. Generates a random jQueryId to use.
        /// </summary>
        /// <param name="account">Account object of the account to use.</param>
        public SteamChatHandler(Account account)
        {
            _account = account;

            //sloppy way to do it, but couldn't get Regex to love me
            _accessToken = GetAccessToken();

            var rand = new Random();
            var jQueryId = (long)(((rand.NextDouble() * 2.0 - 1.0) * long.MaxValue) % 99999999999); //might be able to be larger, haven't checked
            if (jQueryId < 0) jQueryId = -jQueryId;
            _basejQuery = "jQuery" + jQueryId + _account.SteamId + "_{0}";

            _auth = Logon();
        }
예제 #3
0
        /// <summary>
        /// Creates a new SteamChatHandler. Generates a random jQueryId to use.
        /// </summary>
        /// <param name="account">Account object of the account to use.</param>
        public SteamChatHandler(Account account)
        {
            _account = account;

            //sloppy way to do it, but couldn't get Regex to love me
            _accessToken = GetAccessToken();
            if (string.IsNullOrEmpty(_accessToken))
            {
                throw new ChatException(
                          "Error fetching access token, the account specified is not authorized to use this feature.");
            }

            var rand     = new Random();
            var jQueryId = (long)(((rand.NextDouble() * 2.0 - 1.0) * long.MaxValue) % 9999999999999999999);

            jQueryId    = Math.Abs(jQueryId);
            _basejQuery = "jQuery" + jQueryId + "_{0}";

            _auth = Logon();
        }
        /// <summary>
        /// Creates a new SteamChatHandler. Generates a random jQueryId to use.
        /// </summary>
        /// <param name="account">Account object of the account to use.</param>
        public SteamChatHandler(Account account)
        {
            _account = account;

            //sloppy way to do it, but couldn't get Regex to love me
            _accessToken = GetAccessToken();
            if (string.IsNullOrEmpty(_accessToken))
            {
                throw new ChatException(
                    "Error fetching access token, the account specified is not authorized to use this feature.");
            }

            var rand = new Random();
            var jQueryId = (long) (((rand.NextDouble()*2.0 - 1.0)*long.MaxValue)%9999999999999999999);
            jQueryId = Math.Abs(jQueryId);
            _basejQuery = "jQuery" + jQueryId + "_{0}";

            _auth = Logon();

        }
예제 #5
0
        /// <summary>
        /// Logs on to Steam community chat.
        /// </summary>
        /// <returns>WebPresenceOAuthLogonResponse</returns>
        private WebPresenceOAuthLogonResponse Logon()
        {
            const string url    = BaseAuthUrl + "Logon/v0001/";
            string       jQuery = string.Format(_basejQuery, UnixTimeNow());
            var          data   = new Dictionary <string, string>
            {
                { "jsonp", jQuery },
                { "ui_mode", "web" },
                { "access_token", _accessToken }, //special id, like SteamId but not for some reason
                { "_", UnixTimeNow().ToString() }
            };

            string response = _web.Fetch(url, "GET", data, _account.AuthContainer, false).ReadStream();

            //returns an annoying JSON string that can't quite be deserialized yet
            response = StripjQueryArtifacts(response);
            //remove /**/jQuery11110010656769154593349_1442204142816( and remove )

            WebPresenceOAuthLogonResponse webPresenceOAuthLogonResponse =
                JsonConvert.DeserializeObject <WebPresenceOAuthLogonResponse>(response);

            _message = webPresenceOAuthLogonResponse.Message;
            return(webPresenceOAuthLogonResponse);
        }