示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ReadDataSet temp = new ReadDataSet() //发送一个DATASET请求
            {
                TableName = "table1"
            };

            SocketManager.client.SendTo(BufferFormat.FormatFCA(temp));
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            ReadDataSet temp = new ReadDataSet() //发送一个DATASET请求
            {
                TableName = "table1"
            };

            SocketManager.client.SendTo(BufferFormat.FormatFCA(temp, (pdata) => DES.EncryptDES(pdata, keys, "------TEST------")));
        }
示例#3
0
        void client_DataOn(byte[] Data)
        {
            ReadBytes read = new ReadBytes(Data);

            int length;
            int cmd;

            if (read.ReadInt32(out length) && read.ReadInt32(out cmd) && length == read.Length)
            {
                switch (cmd)
                {
                case 800:     //PING命令
                {
                    Ping p;
                    if (read.ReadObject <Ping>(out p))
                    {
                        if (p != null)
                        {
                            this.BeginInvoke(new EventHandler((o, x) =>
                                {
                                    Ping nn = o as Ping;

                                    if (nn != null)
                                    {
                                        toolStripStatusLabel1.Text = string.Format("Ping:{0} ({1})",     //计算并显示PING
                                                                                   (DateTime.Now - nn.UserSendTime).Milliseconds,
                                                                                   (DateTime.Now - nn.ServerReviceTime).Milliseconds);
                                    }
                                }), p);
                        }
                    }
                }
                break;

                case 1002:
                    ReadDataSet dox;
                    if (read.ReadObject <ReadDataSet>(out dox))    //获取服务器发送过来的 DATASET
                    {
                        if (dox != null)
                        {
                            this.BeginInvoke(new EventHandler((o, x) =>
                            {
                                ReadDataSet nn = o as ReadDataSet;

                                if (nn != null)
                                {
                                    this.dataGridView1.DataSource = nn.Data;     //绑定到视图
                                    this.dataGridView1.Update();
                                }
                            }), dox);
                        }
                    }
                    break;
                }
            }
        }