go_dreamfactory/modules/gateway/agentmgr_comp.go
2022-05-31 16:35:44 +08:00

26 lines
601 B
Go

package gateway
import (
"sync"
"github.com/liwei1dao/lego/core"
"github.com/liwei1dao/lego/core/cbase"
)
type AgentMgr_Comp struct {
cbase.ModuleCompBase
agents *sync.Map
}
func (this *AgentMgr_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
this.agents = new(sync.Map)
return
}
func (this *AgentMgr_Comp) Connect(a IAgent) {
this.agents.Store(a.SessionId(), a)
}
func (this *AgentMgr_Comp) DisConnect(a IAgent) {
this.agents.Delete(a.SessionId())
}