Commit ec4517e4 by 施晓雨

update

parent f55475c6
......@@ -32,7 +32,7 @@
this.label1 = new System.Windows.Forms.Label();
this.tbxServiceUrl = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.tbxChannel = new System.Windows.Forms.TextBox();
this.tbxUpdateChannel = new System.Windows.Forms.TextBox();
this.rtbMessage = new System.Windows.Forms.RichTextBox();
this.btnSendMessage = new System.Windows.Forms.Button();
this.btnGet = new System.Windows.Forms.Button();
......@@ -42,7 +42,9 @@
this.tbxPassword = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnAddChannel = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.tbxSubscriptionId = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
......@@ -51,7 +53,8 @@
this.tbxFullName = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.tbxHeartBeatTime = new System.Windows.Forms.TextBox();
this.btnUpdateChannel = new System.Windows.Forms.Button();
this.tbxChannels = new System.Windows.Forms.TextBox();
this.btnRemoveChannel = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
......@@ -93,12 +96,12 @@
this.label2.TabIndex = 1;
this.label2.Text = "发送消息";
//
// tbxChannel
// tbxUpdateChannel
//
this.tbxChannel.Location = new System.Drawing.Point(67, 110);
this.tbxChannel.Name = "tbxChannel";
this.tbxChannel.Size = new System.Drawing.Size(163, 21);
this.tbxChannel.TabIndex = 2;
this.tbxUpdateChannel.Location = new System.Drawing.Point(67, 110);
this.tbxUpdateChannel.Name = "tbxUpdateChannel";
this.tbxUpdateChannel.Size = new System.Drawing.Size(86, 21);
this.tbxUpdateChannel.TabIndex = 2;
//
// rtbMessage
//
......@@ -183,7 +186,9 @@
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnAddChannel);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.tbxSubscriptionId);
this.groupBox2.Controls.Add(this.label9);
......@@ -192,16 +197,27 @@
this.groupBox2.Controls.Add(this.tbxFullName);
this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Controls.Add(this.tbxHeartBeatTime);
this.groupBox2.Controls.Add(this.tbxChannel);
this.groupBox2.Controls.Add(this.btnUpdateChannel);
this.groupBox2.Controls.Add(this.tbxChannels);
this.groupBox2.Controls.Add(this.tbxUpdateChannel);
this.groupBox2.Controls.Add(this.btnRemoveChannel);
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox2.Location = new System.Drawing.Point(0, 84);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(288, 153);
this.groupBox2.Size = new System.Drawing.Size(288, 143);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "状态信息";
//
// btnAddChannel
//
this.btnAddChannel.Location = new System.Drawing.Point(164, 109);
this.btnAddChannel.Name = "btnAddChannel";
this.btnAddChannel.Size = new System.Drawing.Size(47, 23);
this.btnAddChannel.TabIndex = 3;
this.btnAddChannel.Text = "订阅";
this.btnAddChannel.UseVisualStyleBackColor = true;
this.btnAddChannel.Click += new System.EventHandler(this.btnAddChannel_Click);
//
// label7
//
this.label7.AutoSize = true;
......@@ -211,6 +227,15 @@
this.label7.TabIndex = 1;
this.label7.Text = "心跳";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(12, 87);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(53, 12);
this.label10.TabIndex = 1;
this.label10.Text = "我的订阅";
//
// label8
//
this.label8.AutoSize = true;
......@@ -280,15 +305,23 @@
this.tbxHeartBeatTime.Size = new System.Drawing.Size(88, 21);
this.tbxHeartBeatTime.TabIndex = 2;
//
// btnUpdateChannel
// tbxChannels
//
this.tbxChannels.Enabled = false;
this.tbxChannels.Location = new System.Drawing.Point(67, 81);
this.tbxChannels.Name = "tbxChannels";
this.tbxChannels.Size = new System.Drawing.Size(215, 21);
this.tbxChannels.TabIndex = 2;
//
// btnRemoveChannel
//
this.btnUpdateChannel.Location = new System.Drawing.Point(241, 110);
this.btnUpdateChannel.Name = "btnUpdateChannel";
this.btnUpdateChannel.Size = new System.Drawing.Size(41, 23);
this.btnUpdateChannel.TabIndex = 0;
this.btnUpdateChannel.Text = "更新";
this.btnUpdateChannel.UseVisualStyleBackColor = true;
this.btnUpdateChannel.Click += new System.EventHandler(this.btnUpdateChannel_Click);
this.btnRemoveChannel.Location = new System.Drawing.Point(231, 109);
this.btnRemoveChannel.Name = "btnRemoveChannel";
this.btnRemoveChannel.Size = new System.Drawing.Size(51, 23);
this.btnRemoveChannel.TabIndex = 0;
this.btnRemoveChannel.Text = "退订";
this.btnRemoveChannel.UseVisualStyleBackColor = true;
this.btnRemoveChannel.Click += new System.EventHandler(this.btnRemoveChannel_Click);
//
// textBox1
//
......@@ -327,7 +360,7 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox tbxServiceUrl;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox tbxChannel;
private System.Windows.Forms.TextBox tbxUpdateChannel;
private System.Windows.Forms.RichTextBox rtbMessage;
private System.Windows.Forms.Button btnSendMessage;
private System.Windows.Forms.Button btnGet;
......@@ -341,13 +374,16 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox tbxFullName;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button btnUpdateChannel;
private System.Windows.Forms.Button btnRemoveChannel;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox tbxHeartBeatTime;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox tbxConnectedTime;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox tbxChannels;
private System.Windows.Forms.Button btnAddChannel;
}
}
......@@ -63,7 +63,7 @@ namespace Test
btnConnect.Text = "断开";
tbxFullName.Text = connection.DisplayName;
tbxSubscriptionId.Text = connection.Id;
tbxChannel.Text = connection.Channels?.Join(",");
tbxChannels.Text = connection.Channels?.Join(",");
tbxConnectedTime.Text = DateTime.Now.ToString("HH:mm:ss");
tbxConnectedTime.BackColor = tbxConnectedTime.BackColor != Color.MistyRose ? Color.MistyRose : Color.YellowGreen;
......@@ -109,7 +109,11 @@ namespace Test
Invoke(new Action(() => onCommand(command)));
return;
}
rtbMessage.AppendText($"{DateTime.Now.ToString("HH:mm:ss")}:onCommand {command.Json}{Environment.NewLine}{Environment.NewLine}");
if (command is ServerEventUpdate)
{
tbxChannels.Text = (command as ServerEventUpdate).Channels.Join(",");
}
rtbMessage.AppendText($"{DateTime.Now.ToString("HH:mm:ss")}:{command.GetType().Name} {command.Json}{Environment.NewLine}{Environment.NewLine}");
}
......@@ -124,15 +128,29 @@ namespace Test
var id = _client.SubscriptionId;
}
private void btnUpdateChannel_Click(object sender, EventArgs e)
private void btnRemoveChannel_Click(object sender, EventArgs e)
{
btnUpdateChannel.Enabled = false;
var task=_client.SubscribeToChannelsAsync(tbxChannel.Text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
btnRemoveChannel.Enabled = false;
var task=_client.UnsubscribeFromChannelsAsync(tbxUpdateChannel.Text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
task.Success(()=>{
btnUpdateChannel.Enabled = true;
btnRemoveChannel.Enabled = true;
});
task.Error((ex)=> {
btnUpdateChannel.Enabled = true;
btnRemoveChannel.Enabled = true;
rtbMessage.AppendText($"{DateTime.Now.ToString("HH:mm:ss")}:onException {ex.Message}{Environment.NewLine}{Environment.NewLine}");
});
}
private void btnAddChannel_Click(object sender, EventArgs e)
{
btnAddChannel.Enabled = false;
var task = _client.SubscribeToChannelsAsync(tbxUpdateChannel.Text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
task.Success(() => {
btnAddChannel.Enabled = true;
});
task.Error((ex) => {
btnAddChannel.Enabled = true;
rtbMessage.AppendText($"{DateTime.Now.ToString("HH:mm:ss")}:onException {ex.Message}{Environment.NewLine}{Environment.NewLine}");
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment