Skip to content

Commit 438204f

Browse files
authored
Merge branch 'master' into translate_english
2 parents 3cf5b28 + 8948f58 commit 438204f

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

ziface/iclient.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package ziface
66
import "time"
77

88
type IClient interface {
9+
Restart()
910
Start()
1011
Stop()
1112
AddRouter(msgID uint32, router IRouter)

zinterceptor/framedocder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ func (d *FrameDecoder) Decode(buff []byte) [][]byte {
552552
if arr != nil {
553553
//证明已经解析出一个完整包
554554
resp = append(resp, arr)
555-
_size := len(arr)
555+
_size := len(arr) + d.InitialBytesToStrip
556556
//_len := len(this.in)
557557
//fmt.Println(_len)
558558
if _size > 0 {

znet/client.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package znet
33
import (
44
"crypto/tls"
55
"fmt"
6+
"net"
7+
"time"
8+
69
"github.com/aceld/zinx/zconf"
710
"github.com/aceld/zinx/zdecoder"
811
"github.com/aceld/zinx/ziface"
912
"github.com/aceld/zinx/zlog"
1013
"github.com/aceld/zinx/zpack"
1114
"github.com/gorilla/websocket"
12-
"net"
13-
"time"
1415
)
1516

1617
type Client struct {
@@ -105,17 +106,12 @@ func NewTLSClient(ip string, port int, opts ...ClientOption) ziface.IClient {
105106
return c
106107
}
107108

108-
// Start starts the client, sends requests and establishes a connection.
109-
// (启动客户端,发送请求且建立链接)
110-
func (c *Client) Start() {
111109

110+
// Start starts the client, sends requests and establishes a connection.
111+
// (重新启动客户端,发送请求且建立连接)
112+
func (c *Client) Restart() {
112113
c.exitChan = make(chan struct{})
113114

114-
// Add the decoder to the interceptor list (将解码器添加到拦截器)
115-
if c.decoder != nil {
116-
c.msgHandler.AddInterceptor(c.decoder)
117-
}
118-
119115
// Set worker pool size to 0 to turn off the worker pool in the client (客户端将协程池关闭)
120116
zconf.GlobalObject.WorkerPoolSize = 0
121117

@@ -191,6 +187,18 @@ func (c *Client) Start() {
191187
}()
192188
}
193189

190+
// Start starts the client, sends requests and establishes a connection.
191+
// (启动客户端,发送请求且建立链接)
192+
func (c *Client) Start() {
193+
194+
// Add the decoder to the interceptor list (将解码器添加到拦截器)
195+
if c.decoder != nil {
196+
c.msgHandler.AddInterceptor(c.decoder)
197+
}
198+
199+
c.Restart()
200+
}
201+
194202
// StartHeartBeat starts heartbeat detection with a fixed time interval.
195203
// interval: the time interval between each heartbeat message.
196204
// (启动心跳检测, interval: 每次发送心跳的时间间隔)

0 commit comments

Comments
 (0)