刘丹冰
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
4 additions and
3 deletions
-
examples/zinx_client/main.go
-
znet/connection.go
|
@ -56,7 +56,7 @@ func main() { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// fmt.Println("==> Test Router:[Ping] Recv Msg: ID=", msg.Id ", len=", msg.DataLen, ", data=", string(msg.Data))
|
|
|
|
|
|
|
|
|
fmt.Println("==> Test Router:[Ping] Recv Msg: ID=", msg.ID, ", len=", msg.DataLen, ", data=", string(msg.Data)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second) |
|
|
time.Sleep(1 * time.Second) |
|
|
|
@ -158,12 +158,13 @@ func (c *Connection) Start() { |
|
|
|
|
|
|
|
|
//Stop 停止连接,结束当前连接状态M
|
|
|
//Stop 停止连接,结束当前连接状态M
|
|
|
func (c *Connection) Stop() { |
|
|
func (c *Connection) Stop() { |
|
|
c.Lock() |
|
|
|
|
|
defer c.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
//如果用户注册了该链接的关闭回调业务,那么在此刻应该显示调用
|
|
|
//如果用户注册了该链接的关闭回调业务,那么在此刻应该显示调用
|
|
|
c.TCPServer.CallOnConnStop(c) |
|
|
c.TCPServer.CallOnConnStop(c) |
|
|
|
|
|
|
|
|
|
|
|
c.Lock() |
|
|
|
|
|
defer c.Unlock() |
|
|
|
|
|
|
|
|
//如果当前链接已经关闭
|
|
|
//如果当前链接已经关闭
|
|
|
if c.isClosed == true { |
|
|
if c.isClosed == true { |
|
|
return |
|
|
return |
|
|