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
ec4517e4
Commit
ec4517e4
authored
Jul 18, 2019
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f55475c6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
27 deletions
+81
-27
FrmMain.Designer.cs
FrmMain.Designer.cs
+56
-20
FrmMain.cs
FrmMain.cs
+25
-7
No files found.
FrmMain.Designer.cs
View file @
ec4517e4
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxServiceUrl
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxServiceUrl
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxChannel
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbx
Update
Channel
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
rtbMessage
=
new
System
.
Windows
.
Forms
.
RichTextBox
();
this
.
rtbMessage
=
new
System
.
Windows
.
Forms
.
RichTextBox
();
this
.
btnSendMessage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnSendMessage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnGet
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnGet
=
new
System
.
Windows
.
Forms
.
Button
();
...
@@ -42,7 +42,9 @@
...
@@ -42,7 +42,9 @@
this
.
tbxPassword
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxPassword
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
groupBox2
=
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
.
label7
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label10
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label8
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label8
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxSubscriptionId
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxSubscriptionId
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label9
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label9
=
new
System
.
Windows
.
Forms
.
Label
();
...
@@ -51,7 +53,8 @@
...
@@ -51,7 +53,8 @@
this
.
tbxFullName
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxFullName
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label6
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label6
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbxHeartBeatTime
=
new
System
.
Windows
.
Forms
.
TextBox
();
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
.
textBox1
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
groupBox1
.
SuspendLayout
();
this
.
groupBox1
.
SuspendLayout
();
this
.
groupBox2
.
SuspendLayout
();
this
.
groupBox2
.
SuspendLayout
();
...
@@ -93,12 +96,12 @@
...
@@ -93,12 +96,12 @@
this
.
label2
.
TabIndex
=
1
;
this
.
label2
.
TabIndex
=
1
;
this
.
label2
.
Text
=
"发送消息"
;
this
.
label2
.
Text
=
"发送消息"
;
//
//
// tbxChannel
// tbx
Update
Channel
//
//
this
.
tbxChannel
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
110
);
this
.
tbx
Update
Channel
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
110
);
this
.
tbx
Channel
.
Name
=
"tbx
Channel"
;
this
.
tbx
UpdateChannel
.
Name
=
"tbxUpdate
Channel"
;
this
.
tbx
Channel
.
Size
=
new
System
.
Drawing
.
Size
(
163
,
21
);
this
.
tbx
UpdateChannel
.
Size
=
new
System
.
Drawing
.
Size
(
86
,
21
);
this
.
tbxChannel
.
TabIndex
=
2
;
this
.
tbx
Update
Channel
.
TabIndex
=
2
;
//
//
// rtbMessage
// rtbMessage
//
//
...
@@ -183,7 +186,9 @@
...
@@ -183,7 +186,9 @@
//
//
// groupBox2
// groupBox2
//
//
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnAddChannel
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label7
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label7
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label10
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label8
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label8
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxSubscriptionId
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxSubscriptionId
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label9
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label9
);
...
@@ -192,16 +197,27 @@
...
@@ -192,16 +197,27 @@
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxFullName
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxFullName
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label6
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label6
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxHeartBeatTime
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxHeartBeatTime
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxChannel
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxChannels
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnUpdateChannel
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxUpdateChannel
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnRemoveChannel
);
this
.
groupBox2
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
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
,
84
);
this
.
groupBox2
.
Name
=
"groupBox2"
;
this
.
groupBox2
.
Name
=
"groupBox2"
;
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
288
,
1
5
3
);
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
288
,
1
4
3
);
this
.
groupBox2
.
TabIndex
=
6
;
this
.
groupBox2
.
TabIndex
=
6
;
this
.
groupBox2
.
TabStop
=
false
;
this
.
groupBox2
.
TabStop
=
false
;
this
.
groupBox2
.
Text
=
"状态信息"
;
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
// label7
//
//
this
.
label7
.
AutoSize
=
true
;
this
.
label7
.
AutoSize
=
true
;
...
@@ -211,6 +227,15 @@
...
@@ -211,6 +227,15 @@
this
.
label7
.
TabIndex
=
1
;
this
.
label7
.
TabIndex
=
1
;
this
.
label7
.
Text
=
"心跳"
;
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
// label8
//
//
this
.
label8
.
AutoSize
=
true
;
this
.
label8
.
AutoSize
=
true
;
...
@@ -280,15 +305,23 @@
...
@@ -280,15 +305,23 @@
this
.
tbxHeartBeatTime
.
Size
=
new
System
.
Drawing
.
Size
(
88
,
21
);
this
.
tbxHeartBeatTime
.
Size
=
new
System
.
Drawing
.
Size
(
88
,
21
);
this
.
tbxHeartBeatTime
.
TabIndex
=
2
;
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
.
btn
UpdateChannel
.
Location
=
new
System
.
Drawing
.
Point
(
241
,
110
);
this
.
btn
RemoveChannel
.
Location
=
new
System
.
Drawing
.
Point
(
231
,
109
);
this
.
btn
UpdateChannel
.
Name
=
"btnUpdat
eChannel"
;
this
.
btn
RemoveChannel
.
Name
=
"btnRemov
eChannel"
;
this
.
btn
UpdateChannel
.
Size
=
new
System
.
Drawing
.
Size
(
4
1
,
23
);
this
.
btn
RemoveChannel
.
Size
=
new
System
.
Drawing
.
Size
(
5
1
,
23
);
this
.
btn
Updat
eChannel
.
TabIndex
=
0
;
this
.
btn
Remov
eChannel
.
TabIndex
=
0
;
this
.
btn
UpdateChannel
.
Text
=
"更新
"
;
this
.
btn
RemoveChannel
.
Text
=
"退订
"
;
this
.
btn
Updat
eChannel
.
UseVisualStyleBackColor
=
true
;
this
.
btn
Remov
eChannel
.
UseVisualStyleBackColor
=
true
;
this
.
btn
UpdateChannel
.
Click
+=
new
System
.
EventHandler
(
this
.
btnUpdat
eChannel_Click
);
this
.
btn
RemoveChannel
.
Click
+=
new
System
.
EventHandler
(
this
.
btnRemov
eChannel_Click
);
//
//
// textBox1
// textBox1
//
//
...
@@ -327,7 +360,7 @@
...
@@ -327,7 +360,7 @@
private
System
.
Windows
.
Forms
.
Label
label1
;
private
System
.
Windows
.
Forms
.
Label
label1
;
private
System
.
Windows
.
Forms
.
TextBox
tbxServiceUrl
;
private
System
.
Windows
.
Forms
.
TextBox
tbxServiceUrl
;
private
System
.
Windows
.
Forms
.
Label
label2
;
private
System
.
Windows
.
Forms
.
Label
label2
;
private
System
.
Windows
.
Forms
.
TextBox
tbxChannel
;
private
System
.
Windows
.
Forms
.
TextBox
tbx
Update
Channel
;
private
System
.
Windows
.
Forms
.
RichTextBox
rtbMessage
;
private
System
.
Windows
.
Forms
.
RichTextBox
rtbMessage
;
private
System
.
Windows
.
Forms
.
Button
btnSendMessage
;
private
System
.
Windows
.
Forms
.
Button
btnSendMessage
;
private
System
.
Windows
.
Forms
.
Button
btnGet
;
private
System
.
Windows
.
Forms
.
Button
btnGet
;
...
@@ -341,13 +374,16 @@
...
@@ -341,13 +374,16 @@
private
System
.
Windows
.
Forms
.
Label
label5
;
private
System
.
Windows
.
Forms
.
Label
label5
;
private
System
.
Windows
.
Forms
.
TextBox
tbxFullName
;
private
System
.
Windows
.
Forms
.
TextBox
tbxFullName
;
private
System
.
Windows
.
Forms
.
Label
label8
;
private
System
.
Windows
.
Forms
.
Label
label8
;
private
System
.
Windows
.
Forms
.
Button
btn
Updat
eChannel
;
private
System
.
Windows
.
Forms
.
Button
btn
Remov
eChannel
;
private
System
.
Windows
.
Forms
.
TextBox
textBox1
;
private
System
.
Windows
.
Forms
.
TextBox
textBox1
;
private
System
.
Windows
.
Forms
.
Label
label7
;
private
System
.
Windows
.
Forms
.
Label
label7
;
private
System
.
Windows
.
Forms
.
Label
label6
;
private
System
.
Windows
.
Forms
.
Label
label6
;
private
System
.
Windows
.
Forms
.
TextBox
tbxHeartBeatTime
;
private
System
.
Windows
.
Forms
.
TextBox
tbxHeartBeatTime
;
private
System
.
Windows
.
Forms
.
Label
label9
;
private
System
.
Windows
.
Forms
.
Label
label9
;
private
System
.
Windows
.
Forms
.
TextBox
tbxConnectedTime
;
private
System
.
Windows
.
Forms
.
TextBox
tbxConnectedTime
;
private
System
.
Windows
.
Forms
.
Label
label10
;
private
System
.
Windows
.
Forms
.
TextBox
tbxChannels
;
private
System
.
Windows
.
Forms
.
Button
btnAddChannel
;
}
}
}
}
FrmMain.cs
View file @
ec4517e4
...
@@ -63,7 +63,7 @@ namespace Test
...
@@ -63,7 +63,7 @@ namespace Test
btnConnect
.
Text
=
"断开"
;
btnConnect
.
Text
=
"断开"
;
tbxFullName
.
Text
=
connection
.
DisplayName
;
tbxFullName
.
Text
=
connection
.
DisplayName
;
tbxSubscriptionId
.
Text
=
connection
.
Id
;
tbxSubscriptionId
.
Text
=
connection
.
Id
;
tbxChannel
.
Text
=
connection
.
Channels
?.
Join
(
","
);
tbxChannel
s
.
Text
=
connection
.
Channels
?.
Join
(
","
);
tbxConnectedTime
.
Text
=
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
);
tbxConnectedTime
.
Text
=
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
);
tbxConnectedTime
.
BackColor
=
tbxConnectedTime
.
BackColor
!=
Color
.
MistyRose
?
Color
.
MistyRose
:
Color
.
YellowGreen
;
tbxConnectedTime
.
BackColor
=
tbxConnectedTime
.
BackColor
!=
Color
.
MistyRose
?
Color
.
MistyRose
:
Color
.
YellowGreen
;
...
@@ -109,7 +109,11 @@ namespace Test
...
@@ -109,7 +109,11 @@ namespace Test
Invoke
(
new
Action
(()
=>
onCommand
(
command
)));
Invoke
(
new
Action
(()
=>
onCommand
(
command
)));
return
;
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
...
@@ -124,15 +128,29 @@ namespace Test
var
id
=
_client
.
SubscriptionId
;
var
id
=
_client
.
SubscriptionId
;
}
}
private
void
btn
Updat
eChannel_Click
(
object
sender
,
EventArgs
e
)
private
void
btn
Remov
eChannel_Click
(
object
sender
,
EventArgs
e
)
{
{
btn
Updat
eChannel
.
Enabled
=
false
;
btn
Remov
eChannel
.
Enabled
=
false
;
var
task
=
_client
.
SubscribeToChannelsAsync
(
tbx
Channel
.
Text
.
Split
(
new
char
[
1
]
{
','
},
StringSplitOptions
.
RemoveEmptyEntries
));
var
task
=
_client
.
UnsubscribeFromChannelsAsync
(
tbxUpdate
Channel
.
Text
.
Split
(
new
char
[
1
]
{
','
},
StringSplitOptions
.
RemoveEmptyEntries
));
task
.
Success
(()=>{
task
.
Success
(()=>{
btn
Updat
eChannel
.
Enabled
=
true
;
btn
Remov
eChannel
.
Enabled
=
true
;
});
});
task
.
Error
((
ex
)=>
{
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
}
"
);
rtbMessage
.
AppendText
(
$"
{
DateTime
.
Now
.
ToString
(
"HH:mm:ss"
)}
:onException
{
ex
.
Message
}{
Environment
.
NewLine
}{
Environment
.
NewLine
}
"
);
});
});
...
...
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