private void btnSayHelloWorld_Click(object sender, EventArgs e)
        {
            if (xayaService == null)
            {
                MessageBox.Show("Remember to start the xayaService.");
                return;
            }

            if (txtHelloWorld.Text.Length < 20)
            {
                // Guard against JSON injection.
                bool isBad = IsJson(txtHelloWorld.Text);
                if (!isBad)
                {
                    string hello = "{\"g\":{\"helloworld\":{\"m\":\"" + txtHelloWorld.Text + "\"}}}";
                    xayaService.NameUpdate(this.cbxNames.GetItemText(this.cbxNames.SelectedItem), hello, new object());
                }
                else
                {
                    MessageBox.Show("Please don't inject JSON.", "Naughty, naughty!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Text is too long. Limit of 20 chars.");
            }
        }
Example #2
0
        private void btnSayHelloWorld_Click(object sender, EventArgs e)
        {
            if (xayaService == null)
            {
                MessageBox.Show("Remember to start the xayaService.");
                return;
            }

            if (txtHelloWorld.Text.Length < 20)
            {
                string message = JsonConvert.ToString(txtHelloWorld.Text).Trim('"');
                string hello   = "{\"g\":{\"helloworld\":{\"m\":\"" + message + "\"}}}";
                xayaService.NameUpdate(this.cbxNames.GetItemText(this.cbxNames.SelectedItem), hello, new object());
            }
            else
            {
                MessageBox.Show("Text is too long. Limit of 20 chars.");
            }
        }