From 49a163a8229265dec8063259985a9800a880619a Mon Sep 17 00:00:00 2001 From: gufeijun Date: Sun, 21 Feb 2021 16:14:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96=EF=BC=9ANe?= =?UTF-8?q?wConnetion=E6=97=B6=E4=B8=8D=E5=88=9D=E5=A7=8B=E5=8C=96property?= =?UTF-8?q?=20map,=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E9=97=B4=E7=A7=BB?= =?UTF-8?q?=E8=87=B3=E7=AC=AC=E4=B8=80=E6=AC=A1=E8=B0=83=E7=94=A8SetProper?= =?UTF-8?q?ty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- znet/connection.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/znet/connection.go b/znet/connection.go index d99d285..9f11c89 100644 --- a/znet/connection.go +++ b/znet/connection.go @@ -49,7 +49,7 @@ func NewConntion(server ziface.IServer, conn *net.TCPConn, connID uint32, msgHan MsgHandler: msgHandler, msgChan: make(chan []byte), msgBuffChan: make(chan []byte, utils.GlobalObject.MaxMsgChanLen), - property: make(map[string]interface{}), + property: nil, } //将新创建的Conn添加到链接管理中 @@ -250,6 +250,9 @@ func (c *Connection) SendBuffMsg(msgId uint32, data []byte) error { func (c *Connection) SetProperty(key string, value interface{}) { c.propertyLock.Lock() defer c.propertyLock.Unlock() + if c.property == nil { + c.property = make(map[string]interface{}) + } c.property[key] = value }