Ai
1 Star 1 Fork 0

凡卡/libp2parea

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
controller.go 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
凡卡 提交于 2023-11-29 11:01 +08:00 . first commit
package engine
import (
"sync"
)
type Controller interface {
GetSession(areaName []byte, name string) (Session, bool) //通过accId得到客户端的连接Id
GetNet() *Engine //获得连接到本地的计算机连接
SetAttribute(name string, value interface{}) //设置共享数据,实现业务模块之间通信
GetAttribute(name string) interface{} //得到共享数据,实现业务模块之间通信
// GetGroupManager() MsgGroup //获得消息组管理器
}
type ControllerImpl struct {
lock *sync.RWMutex
engine *Engine
attributes map[string]interface{}
// msgGroup *msgGroupManager
}
// 得到net模块,用于给用户发送消息
func (this *ControllerImpl) GetNet() *Engine {
this.lock.RLock()
defer this.lock.RUnlock()
return this.engine
}
func (this *ControllerImpl) SetAttribute(name string, value interface{}) {
this.lock.Lock()
defer this.lock.Unlock()
this.attributes[name] = value
}
func (this *ControllerImpl) GetAttribute(name string) interface{} {
this.lock.RLock()
defer this.lock.RUnlock()
return this.attributes[name]
}
func (this *ControllerImpl) GetSession(areaName []byte, name string) (Session, bool) {
this.lock.RLock()
defer this.lock.RUnlock()
return this.engine.GetSession(areaName, name)
}
// func (this *ControllerImpl) GetGroupManager() MsgGroup {
// return this.msgGroup
// }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/prestonTao/libp2parea.git
git@gitee.com:prestonTao/libp2parea.git
prestonTao
libp2parea
libp2parea
3aaa451ef873

搜索帮助