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
6d471413
Commit
6d471413
authored
Aug 22, 2022
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
up
parent
7f9246ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
22 deletions
+96
-22
FrmMain.Designer.cs
FrmMain.Designer.cs
+70
-11
FrmMain.cs
FrmMain.cs
+26
-11
No files found.
FrmMain.Designer.cs
View file @
6d471413
...
...
@@ -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
,
1
43
);
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
297
,
1
76
);
this
.
groupBox2
.
TabIndex
=
10
;
this
.
groupBox2
.
TabStop
=
false
;
this
.
groupBox2
.
Text
=
"状态信息"
;
//
// btnAddChannel
//
this
.
btnAddChannel
.
Location
=
new
System
.
Drawing
.
Point
(
164
,
1
09
);
this
.
btnAddChannel
.
Location
=
new
System
.
Drawing
.
Point
(
164
,
1
40
);
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
,
1
16
);
this
.
label8
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
1
47
);
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
,
1
10
);
this
.
tbxUpdateChannel
.
Location
=
new
System
.
Drawing
.
Point
(
67
,
1
41
);
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
,
1
09
);
this
.
btnRemoveChannel
.
Location
=
new
System
.
Drawing
.
Point
(
231
,
1
40
);
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
,
2
33
);
this
.
btnGetSubscriptions
.
Location
=
new
System
.
Drawing
.
Point
(
14
,
2
88
);
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
,
2
33
);
this
.
btnClearDebugMessage
.
Location
=
new
System
.
Drawing
.
Point
(
164
,
2
88
);
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
;
}
}
FrmMain.cs
View file @
6d471413
...
...
@@ -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"
};
_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
(()=>{
task
.
Success
((
res
)=>{
tbxAuthSessionId
.
Text
=
res
.
SessionId
;
//登陆成功后连接ServerEvents,设置事件
_client
.
OnConnect
=
onConnected
;
_client
.
OnCommand
=
onCommand
;
_client
.
OnMessage
=
onMessage
;
_client
.
OnException
=
onException
;
_client
.
OnHeartbeat
=
onHeartbeat
;
_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
)
{
}
}
}
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