feat: server.Conn 支持通过 ViewData 函数查看只读的连接数据
This commit is contained in:
parent
433ba08c75
commit
e60e0a754a
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/gorilla/websocket"
|
||||
"github.com/kercylan98/minotaur/server/writeloop"
|
||||
"github.com/kercylan98/minotaur/utils/concurrent"
|
||||
"github.com/kercylan98/minotaur/utils/hash"
|
||||
"github.com/kercylan98/minotaur/utils/log"
|
||||
"github.com/panjf2000/gnet"
|
||||
"github.com/xtaci/kcp-go/v5"
|
||||
|
@ -161,6 +162,11 @@ func (slf *Conn) GetData(key any) any {
|
|||
return slf.data[key]
|
||||
}
|
||||
|
||||
// ViewData 查看只读的连接数据
|
||||
func (slf *Conn) ViewData() map[any]any {
|
||||
return hash.Copy(slf.data)
|
||||
}
|
||||
|
||||
// SetMessageData 设置消息数据,该数据将在消息处理完成后释放
|
||||
func (slf *Conn) SetMessageData(key, value any) *Conn {
|
||||
slf.ctx = context.WithValue(slf.ctx, key, value)
|
||||
|
|
Loading…
Reference in New Issue