Пример #1
0
        private void Received(object sender, MessageReceivedEventArgs e)
        {
            // Report the received message to the user
            this.AppendText("Received: " + e.Message + "\n");

            try
            {
                // Decode the message into an object to be read.
                dynamic msg = JsonConvert.DeserializeObject<dynamic>(e.Message);

                // If it is a registration result, start watching the Gw2 avatar information and register the handler for it.
                if (msg.requestedMethod == "register" && msg.result == true)
                {
                    avatar = new Avatar();
                    avatar.PlayerInfoChanged += new PlayerInfoChangedEventHandler(avatar_PlayerInfoChanged);
                    avatar.StartWatchingPlayerInfo();
                }
            }
            catch (Exception ex)
            {
                // Report to the user that the message couldn't be understood.
                this.AppendText("Could not parse message.\n");
            }
        }