Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
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
wei.xuan
getty
Commits
0e5e138f
Commit
0e5e138f
authored
Jan 29, 2021
by
cvictory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
review issue
parent
e2bdee6b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
client_test.go
client_test.go
+7
-7
getty.go
getty.go
+4
-3
No files found.
client_test.go
View file @
0e5e138f
...
...
@@ -172,7 +172,7 @@ func TestUDPClient(t *testing.T) {
var
(
err
error
conn
*
net
.
UDPConn
leng
int
sendLen
int
totalLen
int
)
func
()
{
...
...
@@ -207,13 +207,13 @@ func TestUDPClient(t *testing.T) {
assert
.
Equal
(
t
,
1
,
msgHandler
.
SessionNumber
())
ss
:=
msgHandler
.
array
[
0
]
totalLen
,
leng
,
err
=
ss
.
WritePkg
(
nil
,
0
)
totalLen
,
sendLen
,
err
=
ss
.
WritePkg
(
nil
,
0
)
assert
.
NotNil
(
t
,
err
)
assert
.
True
(
t
,
leng
==
0
)
assert
.
True
(
t
,
sendLen
==
0
)
assert
.
True
(
t
,
totalLen
==
0
)
totalLen
,
leng
,
err
=
ss
.
WritePkg
([]
byte
(
"hello"
),
0
)
totalLen
,
sendLen
,
err
=
ss
.
WritePkg
([]
byte
(
"hello"
),
0
)
assert
.
NotNil
(
t
,
perrors
.
Cause
(
err
))
assert
.
True
(
t
,
leng
==
0
)
assert
.
True
(
t
,
sendLen
==
0
)
assert
.
True
(
t
,
totalLen
==
0
)
l
,
err
:=
ss
.
WriteBytes
([]
byte
(
"hello"
))
assert
.
Zero
(
t
,
l
)
...
...
@@ -246,10 +246,10 @@ func TestUDPClient(t *testing.T) {
assert
.
Nil
(
t
,
err
)
beforeWritePkgNum
:=
atomic
.
LoadUint32
(
&
udpConn
.
writePkgNum
)
totalLen
,
leng
,
err
=
ss
.
WritePkg
(
udpCtx
,
0
)
totalLen
,
sendLen
,
err
=
ss
.
WritePkg
(
udpCtx
,
0
)
assert
.
Equal
(
t
,
beforeWritePkgNum
+
1
,
atomic
.
LoadUint32
(
&
udpConn
.
writePkgNum
))
assert
.
Nil
(
t
,
err
)
assert
.
True
(
t
,
leng
==
0
)
assert
.
True
(
t
,
sendLen
==
0
)
assert
.
True
(
t
,
totalLen
==
0
)
clt
.
Close
()
...
...
getty.go
View file @
0e5e138f
...
...
@@ -171,9 +171,10 @@ type Session interface {
// the Writer will invoke this function. Pls attention that if timeout is less than 0, WritePkg will send @pkg asap.
// for udp session, the first parameter should be UDPContext.
// total: need send total bytes
// successCount: success send bytes,
WritePkg
(
pkg
interface
{},
timeout
time
.
Duration
)
(
total
int
,
successCount
int
,
e
error
)
// totalBytesLength: @pkg stream bytes length after encoding @pkg.
// sendBytesLength: stream bytes length that sent out successfully.
// err: maybe it has illegal data, encoding error, or write out system error.
WritePkg
(
pkg
interface
{},
timeout
time
.
Duration
)
(
totalBytesLength
int
,
sendBytesLength
int
,
err
error
)
WriteBytes
([]
byte
)
(
int
,
error
)
WriteBytesArray
(
...
[]
byte
)
(
int
,
error
)
Close
()
...
...
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