Files
origin/sysservice/wsagentservice.go
boyce 85a66e4d3d 1.新增websocket agent module对象
2.对module添加SetUnOnRun接口,设置该接口时不会开启协程执行OnRun
2019-06-03 16:38:34 +08:00

42 lines
831 B
Go

package sysservice
import (
"github.com/duanhf2012/origin/network"
"github.com/duanhf2012/origin/service"
)
type WSAgentService struct {
service.BaseService
agentserver network.WSAgentServer
pattern string
port uint16
bEnableCompression bool
}
func (ws *WSAgentService) OnInit() error {
ws.AddModule(&ws.agentserver)
ws.agentserver.Init(ws.port)
return nil
}
func (ws *WSAgentService) OnRun() bool {
ws.agentserver.Start()
return false
}
func NewWSAgentService(port uint16) *WSAgentService {
wss := new(WSAgentService)
wss.port = port
return wss
}
func (ws *WSAgentService) OnDestory() error {
return nil
}
func (ws *WSAgentService) SetupAgent(pattern string, agent network.IAgent, bEnableCompression bool) {
ws.agentserver.SetupAgent(pattern, agent, bEnableCompression)
}