Browse Source

功能增强:给Connction新增Context()方法,返回context

master
gufeijun 4 years ago
parent
commit
848fda9edb
  1. 8
      ziface/iconnection.go
  2. 5
      znet/connection.go

8
ziface/iconnection.go

@ -1,6 +1,9 @@
package ziface package ziface
import "net"
import (
"context"
"net"
)
//定义连接接口 //定义连接接口
type IConnection interface { type IConnection interface {
@ -8,7 +11,8 @@ type IConnection interface {
Start() Start()
//停止连接,结束当前连接状态M //停止连接,结束当前连接状态M
Stop() Stop()
//返回ctx,用于用户自定义的go程获取连接退出状态
Context() context.Context
//从当前连接获取原始的socket TCPConn //从当前连接获取原始的socket TCPConn
GetTCPConnection() *net.TCPConn GetTCPConnection() *net.TCPConn
//获取当前连接ID //获取当前连接ID

5
znet/connection.go

@ -276,3 +276,8 @@ func (c *Connection) RemoveProperty(key string) {
delete(c.property, key) delete(c.property, key)
} }
//返回ctx,用于用户自定义的go程获取连接退出状态
func (c *Connection) Context() context.Context {
return c.ctx
}
Loading…
Cancel
Save