Commit 6d471413 by 施晓雨

up

parent 7f9246ce
......@@ -37,6 +37,7 @@
this.tbxPassword = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.panel1 = new System.Windows.Forms.Panel();
this.btnNotify = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnAddChannel = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
......@@ -57,6 +58,10 @@
this.btnClearDebugMessage = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.rtbMessage = new System.Windows.Forms.RichTextBox();
this.tbxSessionId = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.tbxAuthSessionId = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout();
this.groupBox2.SuspendLayout();
......@@ -127,6 +132,8 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label12);
this.groupBox1.Controls.Add(this.tbxAuthSessionId);
this.groupBox1.Controls.Add(this.tbxServiceUrl);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.tbxUserName);
......@@ -137,13 +144,14 @@
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(297, 84);
this.groupBox1.Size = new System.Drawing.Size(297, 105);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "连接信息";
//
// panel1
//
this.panel1.Controls.Add(this.btnNotify);
this.panel1.Controls.Add(this.groupBox2);
this.panel1.Controls.Add(this.btnGetSubscriptions);
this.panel1.Controls.Add(this.label2);
......@@ -155,10 +163,21 @@
this.panel1.Size = new System.Drawing.Size(297, 680);
this.panel1.TabIndex = 8;
//
// btnNotify
//
this.btnNotify.Location = new System.Drawing.Point(125, 329);
this.btnNotify.Name = "btnNotify";
this.btnNotify.Size = new System.Drawing.Size(105, 23);
this.btnNotify.TabIndex = 11;
this.btnNotify.Text = "发送消息";
this.btnNotify.UseVisualStyleBackColor = true;
this.btnNotify.Click += new System.EventHandler(this.button1_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnAddChannel);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.label11);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.tbxSubscriptionId);
......@@ -168,20 +187,21 @@
this.groupBox2.Controls.Add(this.tbxFullName);
this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Controls.Add(this.tbxHeartBeatTime);
this.groupBox2.Controls.Add(this.tbxSessionId);
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.Location = new System.Drawing.Point(0, 105);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(297, 143);
this.groupBox2.Size = new System.Drawing.Size(297, 176);
this.groupBox2.TabIndex = 10;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "状态信息";
//
// btnAddChannel
//
this.btnAddChannel.Location = new System.Drawing.Point(164, 109);
this.btnAddChannel.Location = new System.Drawing.Point(164, 140);
this.btnAddChannel.Name = "btnAddChannel";
this.btnAddChannel.Size = new System.Drawing.Size(47, 23);
this.btnAddChannel.TabIndex = 3;
......@@ -201,7 +221,7 @@
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(12, 87);
this.label10.Location = new System.Drawing.Point(12, 118);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(53, 12);
this.label10.TabIndex = 1;
......@@ -210,7 +230,7 @@
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(12, 116);
this.label8.Location = new System.Drawing.Point(12, 147);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(53, 12);
this.label8.TabIndex = 1;
......@@ -279,21 +299,21 @@
// tbxChannels
//
this.tbxChannels.Enabled = false;
this.tbxChannels.Location = new System.Drawing.Point(67, 81);
this.tbxChannels.Location = new System.Drawing.Point(67, 112);
this.tbxChannels.Name = "tbxChannels";
this.tbxChannels.Size = new System.Drawing.Size(215, 21);
this.tbxChannels.TabIndex = 2;
//
// tbxUpdateChannel
//
this.tbxUpdateChannel.Location = new System.Drawing.Point(67, 110);
this.tbxUpdateChannel.Location = new System.Drawing.Point(67, 141);
this.tbxUpdateChannel.Name = "tbxUpdateChannel";
this.tbxUpdateChannel.Size = new System.Drawing.Size(86, 21);
this.tbxUpdateChannel.TabIndex = 2;
//
// btnRemoveChannel
//
this.btnRemoveChannel.Location = new System.Drawing.Point(231, 109);
this.btnRemoveChannel.Location = new System.Drawing.Point(231, 140);
this.btnRemoveChannel.Name = "btnRemoveChannel";
this.btnRemoveChannel.Size = new System.Drawing.Size(51, 23);
this.btnRemoveChannel.TabIndex = 0;
......@@ -303,7 +323,7 @@
//
// btnGetSubscriptions
//
this.btnGetSubscriptions.Location = new System.Drawing.Point(14, 233);
this.btnGetSubscriptions.Location = new System.Drawing.Point(14, 288);
this.btnGetSubscriptions.Name = "btnGetSubscriptions";
this.btnGetSubscriptions.Size = new System.Drawing.Size(139, 23);
this.btnGetSubscriptions.TabIndex = 9;
......@@ -322,7 +342,7 @@
//
// btnClearDebugMessage
//
this.btnClearDebugMessage.Location = new System.Drawing.Point(164, 233);
this.btnClearDebugMessage.Location = new System.Drawing.Point(164, 288);
this.btnClearDebugMessage.Name = "btnClearDebugMessage";
this.btnClearDebugMessage.Size = new System.Drawing.Size(118, 23);
this.btnClearDebugMessage.TabIndex = 7;
......@@ -351,6 +371,40 @@
this.rtbMessage.TabIndex = 4;
this.rtbMessage.Text = "";
//
// tbxSessionId
//
this.tbxSessionId.Enabled = false;
this.tbxSessionId.Location = new System.Drawing.Point(67, 82);
this.tbxSessionId.Name = "tbxSessionId";
this.tbxSessionId.Size = new System.Drawing.Size(215, 21);
this.tbxSessionId.TabIndex = 2;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(12, 87);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(53, 12);
this.label11.TabIndex = 1;
this.label11.Text = "会话编号";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(8, 78);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(53, 12);
this.label12.TabIndex = 3;
this.label12.Text = "会话编号";
//
// tbxAuthSessionId
//
this.tbxAuthSessionId.Enabled = false;
this.tbxAuthSessionId.Location = new System.Drawing.Point(67, 73);
this.tbxAuthSessionId.Name = "tbxAuthSessionId";
this.tbxAuthSessionId.Size = new System.Drawing.Size(215, 21);
this.tbxAuthSessionId.TabIndex = 4;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -402,6 +456,11 @@
private System.Windows.Forms.TextBox tbxChannels;
private System.Windows.Forms.TextBox tbxUpdateChannel;
private System.Windows.Forms.Button btnRemoveChannel;
private System.Windows.Forms.Button btnNotify;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox tbxSessionId;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox tbxAuthSessionId;
}
}
......@@ -32,17 +32,25 @@ namespace Test
//连接操作
btnConnect.Enabled=false;
_client = new ServerEventsClient(tbxServiceUrl.Text);
var auth = new Authenticate { UserName =tbxUserName.Text, Password = tbxPassword.Text, provider = "kivii" };
var task=_client.ServiceClient.PostAsync(auth);
task.Success(()=>{
//登陆成功后连接ServerEvents,设置事件
_client.OnConnect = onConnected;
_client.OnCommand = onCommand;
_client.OnMessage = onMessage;
_client.OnException = onException;
_client.OnHeartbeat = onHeartbeat;
_client.Handlers["test"] = testHandler;
//如果用户名为空,匿名连接
if (tbxUserName.Text.IsNullOrEmpty())
{
_client.Connect();
return;
}
var auth = new Authenticate { UserName =tbxUserName.Text, Password = tbxPassword.Text, provider = "kivii" };
var task=_client.ServiceClient.PostAsync(auth);
task.Success((res)=>{
tbxAuthSessionId.Text = res.SessionId;
//登陆成功后连接ServerEvents,设置事件
_client.Connect();
_client.Handlers["test"] = cc;
}, true);
task.Error((ex)=> {
btnConnect.Enabled = true;
......@@ -54,9 +62,11 @@ namespace Test
}
private void cc(ServerEventsClient source, ServerEventMessage args)
private void testHandler(ServerEventsClient source, ServerEventMessage args)
{
throw new NotImplementedException();
rtbMessage.AppendText($"{DateTime.Now.ToString("HH:mm:ss")}:testHandler {args.Data}{Environment.NewLine}{Environment.NewLine}");
rtbMessage.ScrollToCaret();
}
//连接成功,得到连接相应的信息
......@@ -70,7 +80,8 @@ namespace Test
btnConnect.Enabled = true;
btnConnect.Text = "断开";
tbxFullName.Text = connection.DisplayName;
tbxSubscriptionId.Text = connection.Id;
tbxSubscriptionId.Text = connection.SubscriptionId;
tbxSessionId.Text = connection.SessionId;
tbxChannels.Text = connection.Channels?.Join(",");
tbxConnectedTime.Text = DateTime.Now.ToString("HH:mm:ss");
......@@ -194,5 +205,9 @@ namespace Test
{
rtbMessage.Clear();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
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