Пример #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
        public virtual void OnProcessResults(object sender, Notify results)
        {
            var bodies = RtmpUtil.GetBodies(results);

            foreach (var obj in bodies)
            {
                OnProcessObject(this, obj.Item1, obj.Item2);
            }
        }
Пример #3
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);
        }
Пример #4
0
        private void LoginOperation()
        {
            byte[] LoginBody = System.Text.Encoding.UTF8.GetBytes(Username.ToLower() + ":" + SessionToken);
            var    Invoke    = base.InvokeCommandMessage("auth", CommandMessage.LoginOperation, Convert.ToBase64String(LoginBody), DSId);
            var    Body      = RtmpUtil.GetBodies(Invoke).FirstOrDefault();

            if (Body == null || !(Body.Item1 is string))
            {
                Form1.Log("Invalid login");
                return;
            }
            base.InvokeSubscribeMessage("bc", "bc-" + AccountID);
            base.InvokeSubscribeMessage("cn-" + AccountID, "cn-" + AccountID);
            base.InvokeSubscribeMessage("gn-" + AccountID, "gn-" + AccountID);
            LoggedIn  = true;
            Heartbeat = new LCDSHeartbeat(this);
        }
Пример #5
0
        private void dumpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CallView.SelectedItems.Count < 1)
            {
                return;
            }

            var notifies = CallView.SelectedItems[0].Tag as List <Notify>;

            if (notifies == null)
            {
                return;
            }

            using (var sfd = new SaveFileDialog())
            {
                sfd.Filter           = "text files (*.txt)|*.txt";
                sfd.InitialDirectory = Application.StartupPath;
                sfd.RestoreDirectory = true;

                if (sfd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                //TypeName in ASObject is not serialized(Most likely due to inheriting Dictionary?).
                //Lets manually add the TypeName field to the dictionary.
                foreach (var notify in notifies)
                {
                    var bodies = RtmpUtil.GetBodies(notify);
                    foreach (var body in bodies)
                    {
                        AddMissingTypeNames(body.Item1);
                    }
                }

                using (var sw = new StreamWriter(sfd.OpenFile()))
                {
                    sw.Write(JsonConvert.SerializeObject(notifies, Formatting.Indented, new JsonSerializerSettings()
                    {
                        TypeNameHandling = TypeNameHandling.All
                    }));
                }
            }
        }
Пример #6
0
        private void CallView_SelectedIndexChanged(object sender, EventArgs e)
        {
            CallTree.Nodes.Clear();

            if (CallView.SelectedItems.Count < 1)
            {
                return;
            }

            var notifies = CallView.SelectedItems[0].Tag as List <Notify>;

            if (notifies == null)
            {
                return;
            }

            foreach (var notify in notifies)
            {
                var children = new List <TreeNode>();
                var bodies   = RtmpUtil.GetBodies(notify);
                foreach (var body in bodies)
                {
                    children.Add(GetNode(body.Item1) ?? new TreeNode(body.Item1 != null ? body.Item1.ToString() : ""));
                }

                CallTree.Nodes.Add(new TreeNode(!RtmpUtil.IsResult(notify) ? "Call" : "Return", children.ToArray()));
            }

            foreach (TreeNode node in CallTree.Nodes)
            {
                node.Expand();
                foreach (TreeNode node2 in node.Nodes)
                {
                    node2.Expand();
                }
            }
        }
Пример #7
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);
        }