Пример #1
0
        private void SendLoginInfo()
        {
            ASObject body = new ASObject();

            body.Add("username", Username.ToLower());
            body.Add("password", Password);
            body.Add("authToken", AuthToken);
            body.Add("clientVersion", ClientVersion);
            body.Add("ipAddress", IPAddress);
            body.Add("locale", "en_US");
            body.Add("domain", "lolclient.lol.riotgames.com");
            body.Add("operatingSystem", "LolService");
            body.Add("securityAnswer", null);
            body.Add("oldPassword", null);
            body.Add("partnerCredentials", null);
            body.TypeName = "com.riotgames.platform.login.AuthenticationCredentials";

            Notify result = base.InvokeRemotingMessage("loginService", "login", new object[] { body });

            if (RtmpUtil.IsError(result))
            {
                ErrorMessage error = RtmpUtil.GetError(result);
                Form1.Log("Error = " + error.faultString);
                return;
            }

            ASObject args           = (ASObject)RtmpUtil.GetBodies(result).FirstOrDefault().Item1;
            ASObject AccountSummary = (ASObject)args["accountSummary"];

            this.SessionToken = (string)args["token"];
            this.AccountID    = Convert.ToInt32(AccountSummary["accountId"]);
            Form1.Log("SessionToken = " + SessionToken);
            Form1.Log("Account ID: " + AccountID);
        }
Пример #2
0
        /// <summary>
        /// Used to invoke a service which you don't know what it returns.
        /// </summary>
        /// <param name="service"></param>
        /// <param name="operation"></param>
        /// <param name="args"></param>
        /// <returns>ASObject body</returns>
        public object InvokeServiceUnknown(string service, string operation, params object[] args)
        {
            var msg = new RemotingMessage();

            msg.operation   = operation;
            msg.destination = service;
            msg.headers["DSRequestTimeout"] = 60;
            msg.headers["DSId"]             = RtmpUtil.RandomUidString();
            msg.headers["DSEndpoint"]       = "my-rtmps";
            msg.body      = args;
            msg.messageId = RtmpUtil.RandomUidString();

            string endpoint = service + "." + operation;

            var result = Host.Call(msg);

            if (result == null)
            {
                StaticLogger.Warning(string.Format("Invoking {0} returned null", endpoint));
                return(null);
            }

            if (RtmpUtil.IsError(result))
            {
                var error       = RtmpUtil.GetError(result);
                var errordetail = error != null && error.faultDetail != null?string.Format(" [{0}]", error.faultDetail) : "";

                var errorstr = error != null && error.faultString != null?string.Format(", {0}", error.faultString) : "";

                StaticLogger.Warning(string.Format(
                                         "{0} returned an error{1}{2}",
                                         endpoint,
                                         errorstr,
                                         errordetail
                                         ));
                return(null);
            }

            var body = RtmpUtil.GetBodies(result).FirstOrDefault();

            if (body == null)
            {
                StaticLogger.Debug(endpoint + " RtmpUtil.GetBodies returned null");
                return(null);
            }

            return(body.Item1);
        }
Пример #3
0
        public T InvokeService <T>(string service, string operation, params object[] args) where T : class
        {
            var msg = new RemotingMessage();

            msg.operation   = operation;
            msg.destination = service;
            msg.headers["DSRequestTimeout"] = 60;
            msg.headers["DSId"]             = RtmpUtil.RandomUidString();
            msg.headers["DSEndpoint"]       = "my-rtmps";
            msg.body      = args;
            msg.messageId = RtmpUtil.RandomUidString();

            string endpoint = service + "." + operation;

            var result = Host.Call(msg);

            if (result == null)
            {
                StaticLogger.Warning(string.Format("Invoking {0} returned null", endpoint));
                return(null);
            }

            if (RtmpUtil.IsError(result))
            {
                var error       = RtmpUtil.GetError(result);
                var errordetail = error != null && error.faultDetail != null?string.Format(" [{0}]", error.faultDetail) : "";

                var errorstr = error != null && error.faultString != null?string.Format(", {0}", error.faultString) : "";

                StaticLogger.Warning(string.Format(
                                         "{0} returned an error{1}{2}",
                                         endpoint,
                                         errorstr,
                                         errordetail
                                         ));
                return(null);
            }

            var body = RtmpUtil.GetBodies(result).FirstOrDefault();

            if (body == null)
            {
                StaticLogger.Debug(endpoint + " RtmpUtil.GetBodies returned null");
                return(null);
            }

            if (body.Item1 == null)
            {
                StaticLogger.Debug(endpoint + " Body.Item1 returned null");
                return(null);
            }

            object obj = null;

            if (body.Item1 is ASObject)
            {
                var ao = (ASObject)body.Item1;
                obj = MessageTranslator.Instance.GetObject <T>(ao);
                if (obj == null)
                {
                    StaticLogger.Debug(endpoint + " expected " + typeof(T) + ", got " + ao.TypeName);
                    return(null);
                }
            }
            else if (body.Item1 is ArrayCollection)
            {
                try
                {
                    obj = Activator.CreateInstance(typeof(T), (ArrayCollection)body.Item1);
                }
                catch (Exception ex)
                {
                    StaticLogger.Warning(endpoint + " failed to construct " + typeof(T));
                    StaticLogger.Debug(ex);
                    return(null);
                }
            }
            else
            {
                StaticLogger.Debug(endpoint + " unknown object " + body.Item1.GetType());
                return(null);
            }

            if (obj is MessageObject)
            {
                ((MessageObject)obj).TimeStamp = body.Item2;
            }

            return((T)obj);
        }