Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (rb_true.Checked)
                {
                    mClient = new WebSocketTokenClient(new WebSocketReliabilityOptions(true, int.Parse(cb_delay.Text), int.Parse(cb_timeout.Text)));
                }
                else
                {
                    mClient = new WebSocketTokenClient();
                }

                mClient.open += Open;
                mClient.close += Close;
                mClient.error += Error;

                button3.Enabled = true;
                tb_URL.Enabled = true;
                button4.Enabled = false;
                button1.Enabled = false;
                button2.Enabled = true;
            }
            catch (Exception lEx)
            {
                MessageBox.Show("jWebSocket Client Demo", lEx.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (mClient.IsRunning)
     {
         mClient.Close();
         mClient = null;
     }
     button3.Enabled = false;
     tb_URL.Enabled = false;
     button2.Enabled = false;
     button1.Enabled = true;
     button4.Enabled = false;
 }
Example #3
0
 private void BooleanResponse(WebSocketTokenClient sender, TokenResponse e)
 {
     IToken lToken = e.TokenRecive;
     listBox1.Items.Add("Recived token [ type:" + lToken.GetType() + " - NS:" + lToken.GetNS() + " - utid:" + lToken.GetInt("utid") + " - data:" + lToken.GetBool("data") + " ]");
 }
Example #4
0
 private void Open(WebSocketTokenClient sender, WebSocketHeaders e)
 {
     gb_send.Enabled = true;
     button3.Enabled = false;
     tb_URL.Enabled = false;
     button4.Enabled = true;
     listBox1.Items.Add("Connection opened");
     listBox1.Items.Add("JWSSESSIONID = " + e.GetCookies[0].Split('=')[1].Split(';')[0]);
 }
Example #5
0
 private void ListResponse(WebSocketTokenClient sender, TokenResponse e)
 {
     IToken lToken = e.TokenRecive;
     string llist = string.Empty;
     for (int i = 0; i < lToken.GetList("data").Count; i++)
     {
         llist += lToken.GetList("data")[i] + " ";
     }
     listBox1.Items.Add("Recived token [ type:" + lToken.GetType() + " - NS:" + lToken.GetNS() + " - utid:" + lToken.GetInt("utid") + " - data:" + llist + " ]");
 }
Example #6
0
 private void Error(WebSocketTokenClient sender, WebSocketError e)
 {
     listBox1.Items.Add("Error: " + e.Reason);
 }
Example #7
0
 private void Close(WebSocketTokenClient sender, WebSocketCloseReason e)
 {
     gb_send.Enabled = false;
     listBox1.Items.Add("Connection Closed : " + e.ToString());
 }