@@ -3,14 +3,15 @@ package znet
3
3
import (
4
4
"crypto/tls"
5
5
"fmt"
6
+ "net"
7
+ "time"
8
+
6
9
"github.com/aceld/zinx/zconf"
7
10
"github.com/aceld/zinx/zdecoder"
8
11
"github.com/aceld/zinx/ziface"
9
12
"github.com/aceld/zinx/zlog"
10
13
"github.com/aceld/zinx/zpack"
11
14
"github.com/gorilla/websocket"
12
- "net"
13
- "time"
14
15
)
15
16
16
17
type Client struct {
@@ -105,17 +106,12 @@ func NewTLSClient(ip string, port int, opts ...ClientOption) ziface.IClient {
105
106
return c
106
107
}
107
108
108
- // Start starts the client, sends requests and establishes a connection.
109
- // (启动客户端,发送请求且建立链接)
110
- func (c * Client ) Start () {
111
109
110
+ // Start starts the client, sends requests and establishes a connection.
111
+ // (重新启动客户端,发送请求且建立连接)
112
+ func (c * Client ) Restart () {
112
113
c .exitChan = make (chan struct {})
113
114
114
- // Add the decoder to the interceptor list (将解码器添加到拦截器)
115
- if c .decoder != nil {
116
- c .msgHandler .AddInterceptor (c .decoder )
117
- }
118
-
119
115
// Set worker pool size to 0 to turn off the worker pool in the client (客户端将协程池关闭)
120
116
zconf .GlobalObject .WorkerPoolSize = 0
121
117
@@ -191,6 +187,18 @@ func (c *Client) Start() {
191
187
}()
192
188
}
193
189
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
+
194
202
// StartHeartBeat starts heartbeat detection with a fixed time interval.
195
203
// interval: the time interval between each heartbeat message.
196
204
// (启动心跳检测, interval: 每次发送心跳的时间间隔)
0 commit comments