Commit 0e5e138f authored by cvictory's avatar cvictory

review issue

parent e2bdee6b
......@@ -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()
......
......@@ -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()
......
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