Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Client.ServerEvents.Test
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
示例代码
Kivii.Client.ServerEvents.Test
Commits
2200f7f8
Commit
2200f7f8
authored
Jan 14, 2024
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新代码
parent
6019ca53
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
315 additions
and
148 deletions
+315
-148
FrmMain.Designer.cs
FrmMain.Designer.cs
+254
-105
FrmMain.cs
FrmMain.cs
+57
-39
Kivii.Client.ServerEvent.Test.csproj
Kivii.Client.ServerEvent.Test.csproj
+2
-3
packages.config
packages.config
+2
-1
No files found.
FrmMain.Designer.cs
View file @
2200f7f8
...
...
@@ -36,8 +36,24 @@
this
.
label4
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxPassword
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
label12
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxConnectChannels
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
btnClearDebugMessage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
panel1
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
groupBox4
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
rtbToMessage
=
new
System
.
Windows
.
Forms
.
RichTextBox
();
this
.
panel3
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
btnNotify
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnGetSubscriptions
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
panel2
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
cbxToChannel
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
cbxToUserId
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
tbxToSubscriptionId
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
cbxToSubscriptionId
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
tbxToUserId
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
cbxToSessionId
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
tbxToChannel
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxToSessionId
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
groupBox2
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
btnAddChannel
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
label7
=
new
System
.
Windows
.
Forms
.
Label
();
...
...
@@ -47,7 +63,9 @@
this
.
tbxSubscriptionId
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label9
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxConnectedTime
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label13
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label5
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxUserId
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxFullName
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label6
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxHeartBeatTime
=
new
System
.
Windows
.
Forms
.
TextBox
();
...
...
@@ -55,24 +73,21 @@
this
.
tbxChannels
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxUpdateChannel
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
btnRemoveChannel
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnGetSubscriptions
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnClearDebugMessage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
groupBox3
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
rtbMessage
=
new
System
.
Windows
.
Forms
.
RichTextBox
();
this
.
label12
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxConnectChannels
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxUserId
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label13
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
groupBox1
.
SuspendLayout
();
this
.
panel1
.
SuspendLayout
();
this
.
groupBox4
.
SuspendLayout
();
this
.
panel3
.
SuspendLayout
();
this
.
panel2
.
SuspendLayout
();
this
.
groupBox2
.
SuspendLayout
();
this
.
groupBox3
.
SuspendLayout
();
this
.
SuspendLayout
();
//
// btnConnect
//
this
.
btnConnect
.
Location
=
new
System
.
Drawing
.
Point
(
194
,
75
);
this
.
btnConnect
.
Location
=
new
System
.
Drawing
.
Point
(
194
,
80
);
this
.
btnConnect
.
Name
=
"btnConnect"
;
this
.
btnConnect
.
Size
=
new
System
.
Drawing
.
Size
(
41
,
23
);
this
.
btnConnect
.
TabIndex
=
0
;
...
...
@@ -83,7 +98,7 @@
// label1
//
this
.
label1
.
AutoSize
=
true
;
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
2
3
);
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
2
8
);
this
.
label1
.
Name
=
"label1"
;
this
.
label1
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label1
.
TabIndex
=
1
;
...
...
@@ -91,7 +106,7 @@
//
// tbxServiceUrl
//
this
.
tbxServiceUrl
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
2
0
);
this
.
tbxServiceUrl
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
2
5
);
this
.
tbxServiceUrl
.
Name
=
"tbxServiceUrl"
;
this
.
tbxServiceUrl
.
Size
=
new
System
.
Drawing
.
Size
(
215
,
21
);
this
.
tbxServiceUrl
.
TabIndex
=
2
;
...
...
@@ -100,7 +115,7 @@
// label3
//
this
.
label3
.
AutoSize
=
true
;
this
.
label3
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
5
1
);
this
.
label3
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
5
6
);
this
.
label3
.
Name
=
"label3"
;
this
.
label3
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label3
.
TabIndex
=
1
;
...
...
@@ -108,7 +123,7 @@
//
// tbxUserName
//
this
.
tbxUserName
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
47
);
this
.
tbxUserName
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
52
);
this
.
tbxUserName
.
Name
=
"tbxUserName"
;
this
.
tbxUserName
.
Size
=
new
System
.
Drawing
.
Size
(
86
,
21
);
this
.
tbxUserName
.
TabIndex
=
2
;
...
...
@@ -116,7 +131,7 @@
// label4
//
this
.
label4
.
AutoSize
=
true
;
this
.
label4
.
Location
=
new
System
.
Drawing
.
Point
(
159
,
5
1
);
this
.
label4
.
Location
=
new
System
.
Drawing
.
Point
(
159
,
5
6
);
this
.
label4
.
Name
=
"label4"
;
this
.
label4
.
Size
=
new
System
.
Drawing
.
Size
(
29
,
12
);
this
.
label4
.
TabIndex
=
1
;
...
...
@@ -124,7 +139,7 @@
//
// tbxPassword
//
this
.
tbxPassword
.
Location
=
new
System
.
Drawing
.
Point
(
194
,
47
);
this
.
tbxPassword
.
Location
=
new
System
.
Drawing
.
Point
(
194
,
52
);
this
.
tbxPassword
.
Name
=
"tbxPassword"
;
this
.
tbxPassword
.
PasswordChar
=
'*'
;
this
.
tbxPassword
.
Size
=
new
System
.
Drawing
.
Size
(
88
,
21
);
...
...
@@ -143,35 +158,190 @@
this
.
groupBox1
.
Controls
.
Add
(
this
.
label4
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
btnConnect
);
this
.
groupBox1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
groupBox1
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
System
;
this
.
groupBox1
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
groupBox1
.
Name
=
"groupBox1"
;
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
291
,
1
02
);
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
291
,
1
16
);
this
.
groupBox1
.
TabIndex
=
5
;
this
.
groupBox1
.
TabStop
=
false
;
this
.
groupBox1
.
Text
=
"连接信息"
;
//
// label12
//
this
.
label12
.
AutoSize
=
true
;
this
.
label12
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
85
);
this
.
label12
.
Name
=
"label12"
;
this
.
label12
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label12
.
TabIndex
=
3
;
this
.
label12
.
Text
=
"初始频道"
;
//
// tbxConnectChannels
//
this
.
tbxConnectChannels
.
Location
=
new
System
.
Drawing
.
Point
(
66
,
81
);
this
.
tbxConnectChannels
.
Name
=
"tbxConnectChannels"
;
this
.
tbxConnectChannels
.
Size
=
new
System
.
Drawing
.
Size
(
122
,
21
);
this
.
tbxConnectChannels
.
TabIndex
=
4
;
//
// btnClearDebugMessage
//
this
.
btnClearDebugMessage
.
Location
=
new
System
.
Drawing
.
Point
(
241
,
79
);
this
.
btnClearDebugMessage
.
Name
=
"btnClearDebugMessage"
;
this
.
btnClearDebugMessage
.
Size
=
new
System
.
Drawing
.
Size
(
41
,
23
);
this
.
btnClearDebugMessage
.
TabIndex
=
7
;
this
.
btnClearDebugMessage
.
Text
=
"清屏"
;
this
.
btnClearDebugMessage
.
UseVisualStyleBackColor
=
true
;
this
.
btnClearDebugMessage
.
Click
+=
new
System
.
EventHandler
(
this
.
btnClearDebugMessage_Click
);
//
// panel1
//
this
.
panel1
.
Controls
.
Add
(
this
.
btnNotify
);
this
.
panel1
.
Controls
.
Add
(
this
.
groupBox4
);
this
.
panel1
.
Controls
.
Add
(
this
.
groupBox2
);
this
.
panel1
.
Controls
.
Add
(
this
.
btnGetSubscriptions
);
this
.
panel1
.
Controls
.
Add
(
this
.
label2
);
this
.
panel1
.
Controls
.
Add
(
this
.
groupBox1
);
this
.
panel1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
panel1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
panel1
.
Name
=
"panel1"
;
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
291
,
680
);
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
291
,
762
);
this
.
panel1
.
TabIndex
=
8
;
//
// groupBox4
//
this
.
groupBox4
.
Controls
.
Add
(
this
.
rtbToMessage
);
this
.
groupBox4
.
Controls
.
Add
(
this
.
panel3
);
this
.
groupBox4
.
Controls
.
Add
(
this
.
panel2
);
this
.
groupBox4
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
groupBox4
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
groupBox4
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
345
);
this
.
groupBox4
.
Name
=
"groupBox4"
;
this
.
groupBox4
.
Size
=
new
System
.
Drawing
.
Size
(
291
,
417
);
this
.
groupBox4
.
TabIndex
=
12
;
this
.
groupBox4
.
TabStop
=
false
;
this
.
groupBox4
.
Text
=
"测试消息"
;
//
// rtbToMessage
//
this
.
rtbToMessage
.
BorderStyle
=
System
.
Windows
.
Forms
.
BorderStyle
.
FixedSingle
;
this
.
rtbToMessage
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
rtbToMessage
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
158
);
this
.
rtbToMessage
.
Name
=
"rtbToMessage"
;
this
.
rtbToMessage
.
Size
=
new
System
.
Drawing
.
Size
(
285
,
225
);
this
.
rtbToMessage
.
TabIndex
=
15
;
this
.
rtbToMessage
.
Text
=
""
;
//
// panel3
//
this
.
panel3
.
Controls
.
Add
(
this
.
btnNotify
);
this
.
panel3
.
Controls
.
Add
(
this
.
btnGetSubscriptions
);
this
.
panel3
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
panel3
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
383
);
this
.
panel3
.
Name
=
"panel3"
;
this
.
panel3
.
Size
=
new
System
.
Drawing
.
Size
(
285
,
31
);
this
.
panel3
.
TabIndex
=
14
;
//
// btnNotify
//
this
.
btnNotify
.
Location
=
new
System
.
Drawing
.
Point
(
1
25
,
437
);
this
.
btnNotify
.
Location
=
new
System
.
Drawing
.
Point
(
1
69
,
5
);
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
);
this
.
btnNotify
.
Click
+=
new
System
.
EventHandler
(
this
.
btnNotify_Click
);
//
// btnGetSubscriptions
//
this
.
btnGetSubscriptions
.
Location
=
new
System
.
Drawing
.
Point
(
31
,
5
);
this
.
btnGetSubscriptions
.
Name
=
"btnGetSubscriptions"
;
this
.
btnGetSubscriptions
.
Size
=
new
System
.
Drawing
.
Size
(
86
,
23
);
this
.
btnGetSubscriptions
.
TabIndex
=
9
;
this
.
btnGetSubscriptions
.
Text
=
"获取订阅用户"
;
this
.
btnGetSubscriptions
.
UseVisualStyleBackColor
=
true
;
this
.
btnGetSubscriptions
.
Click
+=
new
System
.
EventHandler
(
this
.
btnGetSubscriptions_Click
);
//
// panel2
//
this
.
panel2
.
Controls
.
Add
(
this
.
label2
);
this
.
panel2
.
Controls
.
Add
(
this
.
cbxToChannel
);
this
.
panel2
.
Controls
.
Add
(
this
.
cbxToUserId
);
this
.
panel2
.
Controls
.
Add
(
this
.
tbxToSubscriptionId
);
this
.
panel2
.
Controls
.
Add
(
this
.
cbxToSubscriptionId
);
this
.
panel2
.
Controls
.
Add
(
this
.
tbxToUserId
);
this
.
panel2
.
Controls
.
Add
(
this
.
cbxToSessionId
);
this
.
panel2
.
Controls
.
Add
(
this
.
tbxToChannel
);
this
.
panel2
.
Controls
.
Add
(
this
.
tbxToSessionId
);
this
.
panel2
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
panel2
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
17
);
this
.
panel2
.
Name
=
"panel2"
;
this
.
panel2
.
Size
=
new
System
.
Drawing
.
Size
(
285
,
141
);
this
.
panel2
.
TabIndex
=
13
;
//
// cbxToChannel
//
this
.
cbxToChannel
.
AutoSize
=
true
;
this
.
cbxToChannel
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
12
);
this
.
cbxToChannel
.
Name
=
"cbxToChannel"
;
this
.
cbxToChannel
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbxToChannel
.
TabIndex
=
12
;
this
.
cbxToChannel
.
Text
=
"目标频道"
;
this
.
cbxToChannel
.
UseVisualStyleBackColor
=
true
;
//
// cbxToUserId
//
this
.
cbxToUserId
.
AutoSize
=
true
;
this
.
cbxToUserId
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
96
);
this
.
cbxToUserId
.
Name
=
"cbxToUserId"
;
this
.
cbxToUserId
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbxToUserId
.
TabIndex
=
12
;
this
.
cbxToUserId
.
Text
=
"目标用户"
;
this
.
cbxToUserId
.
UseVisualStyleBackColor
=
true
;
//
// tbxToSubscriptionId
//
this
.
tbxToSubscriptionId
.
Location
=
new
System
.
Drawing
.
Point
(
92
,
62
);
this
.
tbxToSubscriptionId
.
Name
=
"tbxToSubscriptionId"
;
this
.
tbxToSubscriptionId
.
Size
=
new
System
.
Drawing
.
Size
(
184
,
21
);
this
.
tbxToSubscriptionId
.
TabIndex
=
2
;
//
// cbxToSubscriptionId
//
this
.
cbxToSubscriptionId
.
AutoSize
=
true
;
this
.
cbxToSubscriptionId
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
67
);
this
.
cbxToSubscriptionId
.
Name
=
"cbxToSubscriptionId"
;
this
.
cbxToSubscriptionId
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbxToSubscriptionId
.
TabIndex
=
12
;
this
.
cbxToSubscriptionId
.
Text
=
"目标订阅"
;
this
.
cbxToSubscriptionId
.
UseVisualStyleBackColor
=
true
;
//
// tbxToUserId
//
this
.
tbxToUserId
.
Location
=
new
System
.
Drawing
.
Point
(
91
,
91
);
this
.
tbxToUserId
.
Name
=
"tbxToUserId"
;
this
.
tbxToUserId
.
Size
=
new
System
.
Drawing
.
Size
(
184
,
21
);
this
.
tbxToUserId
.
TabIndex
=
2
;
//
// cbxToSessionId
//
this
.
cbxToSessionId
.
AutoSize
=
true
;
this
.
cbxToSessionId
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
40
);
this
.
cbxToSessionId
.
Name
=
"cbxToSessionId"
;
this
.
cbxToSessionId
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbxToSessionId
.
TabIndex
=
12
;
this
.
cbxToSessionId
.
Text
=
"目标会话"
;
this
.
cbxToSessionId
.
UseVisualStyleBackColor
=
true
;
//
// tbxToChannel
//
this
.
tbxToChannel
.
Location
=
new
System
.
Drawing
.
Point
(
91
,
7
);
this
.
tbxToChannel
.
Name
=
"tbxToChannel"
;
this
.
tbxToChannel
.
Size
=
new
System
.
Drawing
.
Size
(
183
,
21
);
this
.
tbxToChannel
.
TabIndex
=
2
;
//
// tbxToSessionId
//
this
.
tbxToSessionId
.
Location
=
new
System
.
Drawing
.
Point
(
91
,
35
);
this
.
tbxToSessionId
.
Name
=
"tbxToSessionId"
;
this
.
tbxToSessionId
.
Size
=
new
System
.
Drawing
.
Size
(
183
,
21
);
this
.
tbxToSessionId
.
TabIndex
=
2
;
//
// groupBox2
//
...
...
@@ -194,16 +364,16 @@
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
,
1
02
);
this
.
groupBox2
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
1
16
);
this
.
groupBox2
.
Name
=
"groupBox2"
;
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
291
,
2
1
9
);
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
291
,
2
2
9
);
this
.
groupBox2
.
TabIndex
=
10
;
this
.
groupBox2
.
TabStop
=
false
;
this
.
groupBox2
.
Text
=
"状态信息"
;
//
// btnAddChannel
//
this
.
btnAddChannel
.
Location
=
new
System
.
Drawing
.
Point
(
1
78
,
179
);
this
.
btnAddChannel
.
Location
=
new
System
.
Drawing
.
Point
(
1
88
,
185
);
this
.
btnAddChannel
.
Name
=
"btnAddChannel"
;
this
.
btnAddChannel
.
Size
=
new
System
.
Drawing
.
Size
(
47
,
23
);
this
.
btnAddChannel
.
TabIndex
=
3
;
...
...
@@ -214,7 +384,7 @@
// label7
//
this
.
label7
.
AutoSize
=
true
;
this
.
label7
.
Location
=
new
System
.
Drawing
.
Point
(
162
,
24
);
this
.
label7
.
Location
=
new
System
.
Drawing
.
Point
(
162
,
30
);
this
.
label7
.
Name
=
"label7"
;
this
.
label7
.
Size
=
new
System
.
Drawing
.
Size
(
29
,
12
);
this
.
label7
.
TabIndex
=
1
;
...
...
@@ -223,7 +393,7 @@
// label11
//
this
.
label11
.
AutoSize
=
true
;
this
.
label11
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
76
);
this
.
label11
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
82
);
this
.
label11
.
Name
=
"label11"
;
this
.
label11
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label11
.
TabIndex
=
1
;
...
...
@@ -232,7 +402,7 @@
// label10
//
this
.
label10
.
AutoSize
=
true
;
this
.
label10
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
5
3
);
this
.
label10
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
5
9
);
this
.
label10
.
Name
=
"label10"
;
this
.
label10
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label10
.
TabIndex
=
1
;
...
...
@@ -241,7 +411,7 @@
// label8
//
this
.
label8
.
AutoSize
=
true
;
this
.
label8
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
1
86
);
this
.
label8
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
1
92
);
this
.
label8
.
Name
=
"label8"
;
this
.
label8
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label8
.
TabIndex
=
1
;
...
...
@@ -249,7 +419,7 @@
//
// tbxSubscriptionId
//
this
.
tbxSubscriptionId
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
98
);
this
.
tbxSubscriptionId
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
104
);
this
.
tbxSubscriptionId
.
Name
=
"tbxSubscriptionId"
;
this
.
tbxSubscriptionId
.
ReadOnly
=
true
;
this
.
tbxSubscriptionId
.
Size
=
new
System
.
Drawing
.
Size
(
215
,
21
);
...
...
@@ -258,7 +428,7 @@
// label9
//
this
.
label9
.
AutoSize
=
true
;
this
.
label9
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
24
);
this
.
label9
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
30
);
this
.
label9
.
Name
=
"label9"
;
this
.
label9
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label9
.
TabIndex
=
1
;
...
...
@@ -266,24 +436,41 @@
//
// tbxConnectedTime
//
this
.
tbxConnectedTime
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
19
);
this
.
tbxConnectedTime
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
25
);
this
.
tbxConnectedTime
.
Name
=
"tbxConnectedTime"
;
this
.
tbxConnectedTime
.
ReadOnly
=
true
;
this
.
tbxConnectedTime
.
Size
=
new
System
.
Drawing
.
Size
(
86
,
21
);
this
.
tbxConnectedTime
.
TabIndex
=
2
;
//
// label13
//
this
.
label13
.
AutoSize
=
true
;
this
.
label13
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
163
);
this
.
label13
.
Name
=
"label13"
;
this
.
label13
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label13
.
TabIndex
=
1
;
this
.
label13
.
Text
=
"用户编号"
;
//
// label5
//
this
.
label5
.
AutoSize
=
true
;
this
.
label5
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
13
0
);
this
.
label5
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
13
6
);
this
.
label5
.
Name
=
"label5"
;
this
.
label5
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label5
.
TabIndex
=
1
;
this
.
label5
.
Text
=
"用户姓名"
;
//
// tbxUserId
//
this
.
tbxUserId
.
Location
=
new
System
.
Drawing
.
Point
(
66
,
158
);
this
.
tbxUserId
.
Name
=
"tbxUserId"
;
this
.
tbxUserId
.
ReadOnly
=
true
;
this
.
tbxUserId
.
Size
=
new
System
.
Drawing
.
Size
(
214
,
21
);
this
.
tbxUserId
.
TabIndex
=
2
;
//
// tbxFullName
//
this
.
tbxFullName
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
1
25
);
this
.
tbxFullName
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
1
31
);
this
.
tbxFullName
.
Name
=
"tbxFullName"
;
this
.
tbxFullName
.
ReadOnly
=
true
;
this
.
tbxFullName
.
Size
=
new
System
.
Drawing
.
Size
(
214
,
21
);
...
...
@@ -292,7 +479,7 @@
// label6
//
this
.
label6
.
AutoSize
=
true
;
this
.
label6
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
10
3
);
this
.
label6
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
10
9
);
this
.
label6
.
Name
=
"label6"
;
this
.
label6
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label6
.
TabIndex
=
1
;
...
...
@@ -302,14 +489,14 @@
//
this
.
tbxHeartBeatTime
.
BackColor
=
System
.
Drawing
.
Color
.
YellowGreen
;
this
.
tbxHeartBeatTime
.
Enabled
=
false
;
this
.
tbxHeartBeatTime
.
Location
=
new
System
.
Drawing
.
Point
(
194
,
2
0
);
this
.
tbxHeartBeatTime
.
Location
=
new
System
.
Drawing
.
Point
(
194
,
2
6
);
this
.
tbxHeartBeatTime
.
Name
=
"tbxHeartBeatTime"
;
this
.
tbxHeartBeatTime
.
Size
=
new
System
.
Drawing
.
Size
(
88
,
21
);
this
.
tbxHeartBeatTime
.
TabIndex
=
2
;
//
// tbxSessionId
//
this
.
tbxSessionId
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
7
1
);
this
.
tbxSessionId
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
7
7
);
this
.
tbxSessionId
.
Name
=
"tbxSessionId"
;
this
.
tbxSessionId
.
ReadOnly
=
true
;
this
.
tbxSessionId
.
Size
=
new
System
.
Drawing
.
Size
(
215
,
21
);
...
...
@@ -317,7 +504,7 @@
//
// tbxChannels
//
this
.
tbxChannels
.
Location
=
new
System
.
Drawing
.
Point
(
66
,
47
);
this
.
tbxChannels
.
Location
=
new
System
.
Drawing
.
Point
(
66
,
53
);
this
.
tbxChannels
.
Name
=
"tbxChannels"
;
this
.
tbxChannels
.
ReadOnly
=
true
;
this
.
tbxChannels
.
Size
=
new
System
.
Drawing
.
Size
(
215
,
21
);
...
...
@@ -325,14 +512,14 @@
//
// tbxUpdateChannel
//
this
.
tbxUpdateChannel
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
18
0
);
this
.
tbxUpdateChannel
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
18
6
);
this
.
tbxUpdateChannel
.
Name
=
"tbxUpdateChannel"
;
this
.
tbxUpdateChannel
.
Size
=
new
System
.
Drawing
.
Size
(
1
0
5
,
21
);
this
.
tbxUpdateChannel
.
Size
=
new
System
.
Drawing
.
Size
(
1
1
5
,
21
);
this
.
tbxUpdateChannel
.
TabIndex
=
2
;
//
// btnRemoveChannel
//
this
.
btnRemoveChannel
.
Location
=
new
System
.
Drawing
.
Point
(
231
,
1
79
);
this
.
btnRemoveChannel
.
Location
=
new
System
.
Drawing
.
Point
(
231
,
1
85
);
this
.
btnRemoveChannel
.
Name
=
"btnRemoveChannel"
;
this
.
btnRemoveChannel
.
Size
=
new
System
.
Drawing
.
Size
(
51
,
23
);
this
.
btnRemoveChannel
.
TabIndex
=
0
;
...
...
@@ -340,42 +527,13 @@
this
.
btnRemoveChannel
.
UseVisualStyleBackColor
=
true
;
this
.
btnRemoveChannel
.
Click
+=
new
System
.
EventHandler
(
this
.
btnRemoveChannel_Click
);
//
// btnGetSubscriptions
//
this
.
btnGetSubscriptions
.
Location
=
new
System
.
Drawing
.
Point
(
14
,
396
);
this
.
btnGetSubscriptions
.
Name
=
"btnGetSubscriptions"
;
this
.
btnGetSubscriptions
.
Size
=
new
System
.
Drawing
.
Size
(
139
,
23
);
this
.
btnGetSubscriptions
.
TabIndex
=
9
;
this
.
btnGetSubscriptions
.
Text
=
"获取频道的所有订阅人"
;
this
.
btnGetSubscriptions
.
UseVisualStyleBackColor
=
true
;
this
.
btnGetSubscriptions
.
Click
+=
new
System
.
EventHandler
(
this
.
btnGetSubscriptions_Click
);
//
// label2
//
this
.
label2
.
AutoSize
=
true
;
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
48
,
442
);
this
.
label2
.
Name
=
"label2"
;
this
.
label2
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label2
.
TabIndex
=
8
;
this
.
label2
.
Text
=
"发送消息"
;
//
// btnClearDebugMessage
//
this
.
btnClearDebugMessage
.
Location
=
new
System
.
Drawing
.
Point
(
241
,
74
);
this
.
btnClearDebugMessage
.
Name
=
"btnClearDebugMessage"
;
this
.
btnClearDebugMessage
.
Size
=
new
System
.
Drawing
.
Size
(
41
,
23
);
this
.
btnClearDebugMessage
.
TabIndex
=
7
;
this
.
btnClearDebugMessage
.
Text
=
"清屏"
;
this
.
btnClearDebugMessage
.
UseVisualStyleBackColor
=
true
;
this
.
btnClearDebugMessage
.
Click
+=
new
System
.
EventHandler
(
this
.
btnClearDebugMessage_Click
);
//
// groupBox3
//
this
.
groupBox3
.
Controls
.
Add
(
this
.
rtbMessage
);
this
.
groupBox3
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
groupBox3
.
Location
=
new
System
.
Drawing
.
Point
(
291
,
0
);
this
.
groupBox3
.
Name
=
"groupBox3"
;
this
.
groupBox3
.
Size
=
new
System
.
Drawing
.
Size
(
711
,
680
);
this
.
groupBox3
.
Size
=
new
System
.
Drawing
.
Size
(
968
,
762
);
this
.
groupBox3
.
TabIndex
=
9
;
this
.
groupBox3
.
TabStop
=
false
;
this
.
groupBox3
.
Text
=
"调试信息"
;
...
...
@@ -386,48 +544,24 @@
this
.
rtbMessage
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
rtbMessage
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
17
);
this
.
rtbMessage
.
Name
=
"rtbMessage"
;
this
.
rtbMessage
.
Size
=
new
System
.
Drawing
.
Size
(
705
,
660
);
this
.
rtbMessage
.
Size
=
new
System
.
Drawing
.
Size
(
962
,
742
);
this
.
rtbMessage
.
TabIndex
=
4
;
this
.
rtbMessage
.
Text
=
""
;
//
// label12
//
this
.
label12
.
AutoSize
=
true
;
this
.
label12
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
80
);
this
.
label12
.
Name
=
"label12"
;
this
.
label12
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label12
.
TabIndex
=
3
;
this
.
label12
.
Text
=
"初始频道"
;
//
// tbxConnectChannels
//
this
.
tbxConnectChannels
.
Location
=
new
System
.
Drawing
.
Point
(
66
,
76
);
this
.
tbxConnectChannels
.
Name
=
"tbxConnectChannels"
;
this
.
tbxConnectChannels
.
Size
=
new
System
.
Drawing
.
Size
(
122
,
21
);
this
.
tbxConnectChannels
.
TabIndex
=
4
;
//
// tbxUserId
//
this
.
tbxUserId
.
Location
=
new
System
.
Drawing
.
Point
(
66
,
152
);
this
.
tbxUserId
.
Name
=
"tbxUserId"
;
this
.
tbxUserId
.
ReadOnly
=
true
;
this
.
tbxUserId
.
Size
=
new
System
.
Drawing
.
Size
(
214
,
21
);
this
.
tbxUserId
.
TabIndex
=
2
;
//
// label13
// label2
//
this
.
label
13
.
AutoSize
=
true
;
this
.
label
13
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
157
);
this
.
label
13
.
Name
=
"label13
"
;
this
.
label
13
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label
13
.
TabIndex
=
1
;
this
.
label
13
.
Text
=
"用户编号
"
;
this
.
label
2
.
AutoSize
=
true
;
this
.
label
2
.
Location
=
new
System
.
Drawing
.
Point
(
8
,
126
);
this
.
label
2
.
Name
=
"label2
"
;
this
.
label
2
.
Size
=
new
System
.
Drawing
.
Size
(
119
,
12
);
this
.
label
2
.
TabIndex
=
13
;
this
.
label
2
.
Text
=
"消息正文(JSON格式)
"
;
//
// FrmMain
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1
002
,
680
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1
259
,
762
);
this
.
Controls
.
Add
(
this
.
groupBox3
);
this
.
Controls
.
Add
(
this
.
panel1
);
this
.
Name
=
"FrmMain"
;
...
...
@@ -435,7 +569,10 @@
this
.
groupBox1
.
ResumeLayout
(
false
);
this
.
groupBox1
.
PerformLayout
();
this
.
panel1
.
ResumeLayout
(
false
);
this
.
panel1
.
PerformLayout
();
this
.
groupBox4
.
ResumeLayout
(
false
);
this
.
panel3
.
ResumeLayout
(
false
);
this
.
panel2
.
ResumeLayout
(
false
);
this
.
panel2
.
PerformLayout
();
this
.
groupBox2
.
ResumeLayout
(
false
);
this
.
groupBox2
.
PerformLayout
();
this
.
groupBox3
.
ResumeLayout
(
false
);
...
...
@@ -455,7 +592,6 @@
private
System
.
Windows
.
Forms
.
GroupBox
groupBox1
;
private
System
.
Windows
.
Forms
.
Panel
panel1
;
private
System
.
Windows
.
Forms
.
Button
btnGetSubscriptions
;
private
System
.
Windows
.
Forms
.
Label
label2
;
private
System
.
Windows
.
Forms
.
Button
btnClearDebugMessage
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox3
;
private
System
.
Windows
.
Forms
.
RichTextBox
rtbMessage
;
...
...
@@ -481,6 +617,19 @@
private
System
.
Windows
.
Forms
.
TextBox
tbxConnectChannels
;
private
System
.
Windows
.
Forms
.
Label
label13
;
private
System
.
Windows
.
Forms
.
TextBox
tbxUserId
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox4
;
private
System
.
Windows
.
Forms
.
RichTextBox
rtbToMessage
;
private
System
.
Windows
.
Forms
.
Panel
panel3
;
private
System
.
Windows
.
Forms
.
Panel
panel2
;
private
System
.
Windows
.
Forms
.
CheckBox
cbxToChannel
;
private
System
.
Windows
.
Forms
.
CheckBox
cbxToUserId
;
private
System
.
Windows
.
Forms
.
TextBox
tbxToSubscriptionId
;
private
System
.
Windows
.
Forms
.
CheckBox
cbxToSubscriptionId
;
private
System
.
Windows
.
Forms
.
TextBox
tbxToUserId
;
private
System
.
Windows
.
Forms
.
CheckBox
cbxToSessionId
;
private
System
.
Windows
.
Forms
.
TextBox
tbxToChannel
;
private
System
.
Windows
.
Forms
.
TextBox
tbxToSessionId
;
private
System
.
Windows
.
Forms
.
Label
label2
;
}
}
FrmMain.cs
View file @
2200f7f8
using
Kivii
;
using
Kivii.Text
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
...
...
@@ -18,7 +19,12 @@ namespace Test
{
InitializeComponent
();
}
#
region
连接
SSE
以及相应的事件响应
/// <summary>
/// 连接SSE
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
btnConnect_Click
(
object
sender
,
EventArgs
e
)
{
if
(
_client
!=
null
)
//断开操作
...
...
@@ -33,11 +39,11 @@ namespace Test
btnConnect
.
Enabled
=
false
;
_client
=
new
ServerEventsClient
(
tbxServiceUrl
.
Text
);
_client
.
OnConnect
=
onConnected
;
//连接成功
_client
.
OnCommand
=
onCommand
;
//收到命令
_client
.
OnMessage
=
o
nMessage
;
//收到消息
_client
.
OnException
=
o
nException
;
//发生异常
_client
.
OnHeartbeat
=
o
nHeartbeat
;
//心跳
_client
.
Handlers
[
"test"
]
=
testHandler
;
_client
.
OnCommand
=
sse_OnCommand
;
//收到命令,指cmd.onJoin,cmd.onLeave,cmd.onUpdate,即有订阅者加入、离开频道,或更新了信息
_client
.
OnMessage
=
sse_O
nMessage
;
//收到消息
_client
.
OnException
=
sse_O
nException
;
//发生异常
_client
.
OnHeartbeat
=
sse_O
nHeartbeat
;
//心跳
_client
.
Handlers
[
"test"
]
=
sse_OnCustomHandler
;
//当发送的Selector为cmd.test时,会触发这个事件
_client
.
Channels
=
tbxConnectChannels
.
Text
.
Split
(
new
char
[
1
]
{
','
},
StringSplitOptions
.
RemoveEmptyEntries
);
//如果用户名为空,匿名连接
if
(
tbxUserName
.
Text
.
IsNullOrEmpty
())
...
...
@@ -62,13 +68,6 @@ namespace Test
}
private
void
testHandler
(
ServerEventsClient
source
,
ServerEventMessage
args
)
{
rtbMessage
.
AppendText
(
$"
{
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
)}
:testHandler
{
args
.
Data
}{
Environment
.
NewLine
}{
Environment
.
NewLine
}
"
);
rtbMessage
.
ScrollToCaret
();
}
//连接成功,得到连接相应的信息
private
void
onConnected
(
ServerEventConnect
connection
)
{
...
...
@@ -91,76 +90,74 @@ namespace Test
rtbMessage
.
ScrollToCaret
();
}
//得到心跳包
private
void
o
nHeartbeat
()
private
void
sse_O
nHeartbeat
()
{
if
(
InvokeRequired
)
{
Invoke
(
new
Action
(
o
nHeartbeat
));
Invoke
(
new
Action
(
sse_O
nHeartbeat
));
return
;
}
tbxHeartBeatTime
.
BackColor
=
tbxHeartBeatTime
.
BackColor
!=
Color
.
MistyRose
?
Color
.
MistyRose
:
Color
.
YellowGreen
;
tbxHeartBeatTime
.
Text
=
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
);
}
//出现异常
private
void
o
nException
(
Exception
ex
)
private
void
sse_O
nException
(
Exception
ex
)
{
if
(
InvokeRequired
)
{
Invoke
(
new
Action
(()
=>
o
nException
(
ex
)));
Invoke
(
new
Action
(()
=>
sse_O
nException
(
ex
)));
return
;
}
rtbMessage
.
AppendText
(
$"
{
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
)}
:onException
{
ex
.
Message
}{
Environment
.
NewLine
}{
Environment
.
NewLine
}
"
);
rtbMessage
.
ScrollToCaret
();
}
//得到消息
private
void
o
nMessage
(
ServerEventMessage
message
)
private
void
sse_O
nMessage
(
ServerEventMessage
message
)
{
if
(
InvokeRequired
)
{
Invoke
(
new
Action
(()
=>
o
nMessage
(
message
)));
Invoke
(
new
Action
(()
=>
sse_O
nMessage
(
message
)));
return
;
}
rtbMessage
.
AppendText
(
$"
{
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
)}
:onMessage
{
message
.
Json
}{
Environment
.
NewLine
}{
Environment
.
NewLine
}
"
);
rtbMessage
.
ScrollToCaret
();
}
//得到命令
private
void
o
nCommand
(
ServerEventMessage
command
)
private
void
sse_O
nCommand
(
ServerEventMessage
command
)
{
if
(
InvokeRequired
)
{
Invoke
(
new
Action
(()
=>
o
nCommand
(
command
)));
Invoke
(
new
Action
(()
=>
sse_O
nCommand
(
command
)));
return
;
}
var
eventUpdate
=
command
as
ServerEventUpdate
;
if
(
eventUpdate
!=
null
&&
eventUpdate
.
SubscriptionId
==
_client
.
ConnectionInfo
.
SubscriptionId
)
if
(
eventUpdate
!=
null
&&
eventUpdate
.
SubscriptionId
==
_client
.
ConnectionInfo
.
SubscriptionId
)
{
tbxChannels
.
Text
=
eventUpdate
.
Channels
.
Join
(
","
);
}
rtbMessage
.
AppendText
(
$"
{
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
)}
:
{
command
.
GetType
().
Name
}
{
command
.
Json
}{
Environment
.
NewLine
}{
Environment
.
NewLine
}
"
);
rtbMessage
.
ScrollToCaret
();
}
private
void
btnSendMessage_Click
(
object
sender
,
EventArgs
e
)
//自定义的
private
void
sse_OnCustomHandler
(
ServerEventsClient
source
,
ServerEventMessage
args
)
{
}
private
void
btnGet_Click
(
object
sender
,
EventArgs
e
)
{
var
users
=
_client
.
GetChannelSubscribers
();
var
id
=
_client
.
SubscriptionId
;
rtbMessage
.
AppendText
(
$"
{
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
)}
:testHandler
{
args
.
Data
}{
Environment
.
NewLine
}{
Environment
.
NewLine
}
"
);
rtbMessage
.
ScrollToCaret
();
}
#
endregion
#
region
订阅频道更新操作
private
void
btnRemoveChannel_Click
(
object
sender
,
EventArgs
e
)
{
btnRemoveChannel
.
Enabled
=
false
;
var
task
=
_client
.
UnsubscribeFromChannelsAsync
(
tbxUpdateChannel
.
Text
.
Split
(
new
char
[
1
]
{
','
},
StringSplitOptions
.
RemoveEmptyEntries
));
task
.
Success
(()
=>
{
var
task
=
_client
.
UnsubscribeFromChannelsAsync
(
tbxUpdateChannel
.
Text
.
Split
(
new
char
[
1
]
{
','
},
StringSplitOptions
.
RemoveEmptyEntries
));
task
.
Success
(()
=>
{
tbxChannels
.
Text
=
_client
.
Channels
.
Join
(
","
);
btnRemoveChannel
.
Enabled
=
true
;
});
task
.
Error
((
ex
)=>
{
task
.
Error
((
ex
)
=>
{
btnRemoveChannel
.
Enabled
=
true
;
rtbMessage
.
AppendText
(
$"
{
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
)}
:onException
{
ex
.
Message
}{
Environment
.
NewLine
}{
Environment
.
NewLine
}
"
);
rtbMessage
.
ScrollToCaret
();
...
...
@@ -183,14 +180,37 @@ namespace Test
});
}
#
endregion
#
region
发送消息
private
void
btnNotify_Click
(
object
sender
,
EventArgs
e
)
{
var
message
=
new
EventMessageRequest
();
message
.
Channel
=
cbxToChannel
.
Checked
?
tbxToChannel
.
Text
:
null
;
message
.
SubscriptionId
=
cbxToSubscriptionId
.
Checked
?
tbxToSubscriptionId
.
Text
:
null
;
message
.
SessionId
=
cbxToSessionId
.
Checked
?
tbxToSessionId
.
Text
:
null
;
message
.
UserId
=
cbxToUserId
.
Checked
?
tbxToUserId
.
Text
:
null
;
message
.
Message
=
JsonObject
.
Parse
(
rtbToMessage
.
Text
);
_client
.
SendMessageAsync
(
message
).
Success
(
res
=>
{
rtbMessage
.
AppendText
(
$"
{
Environment
.
NewLine
}
发送结果:
{
res
.
ToJson
()}{
Environment
.
NewLine
}
"
);
});
}
#
endregion
private
void
btnGet_Click
(
object
sender
,
EventArgs
e
)
{
var
users
=
_client
.
GetChannelSubscribers
();
var
id
=
_client
.
SubscriptionId
;
}
private
void
btnGetSubscriptions_Click
(
object
sender
,
EventArgs
e
)
{
btnGetSubscriptions
.
Enabled
=
false
;
var
task
=
_client
.
GetChannelSubscribersAsync
();
task
.
Success
(()
=>
{
task
.
Success
((
res
)
=>
{
btnGetSubscriptions
.
Enabled
=
true
;
foreach
(
var
item
in
task
.
Result
)
foreach
(
var
item
in
res
)
{
rtbMessage
.
AppendText
(
$"DisplayName:
{
item
.
DisplayName
}
,UserId:
{
item
.
UserId
}
,SubscriptionId:
{
item
.
SubscriptionId
}
,Channels:
{
item
.
Channels
.
Join
()}{
Environment
.
NewLine
}
"
);
rtbMessage
.
ScrollToCaret
();
...
...
@@ -208,8 +228,6 @@ namespace Test
rtbMessage
.
Clear
();
}
private
void
button1_Click
(
object
sender
,
EventArgs
e
)
{
}
}
}
Kivii.Client.ServerEvent.Test.csproj
View file @
2200f7f8
...
...
@@ -32,9 +32,8 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Kivii.Common.V4.5, Version=5.6.2024.1140, Culture=neutral, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\..\localhost\net45\app\Kivii.Common.V4.5.dll
</HintPath>
<Reference
Include=
"Kivii.Common.V4.5, Version=5.6.2024.1150, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
packages\Kivii.Common.5.6.2024.1150\lib\net45\Kivii.Common.V4.5.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
...
...
packages.config
View file @
2200f7f8
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Kivii.Common"
version
=
"5.6.2024.11
4
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Common"
version
=
"5.6.2024.11
5
0"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment