mirror of
https://github.com/duanhf2012/origin.git
synced 2026-03-06 14:17:31 +08:00
1.新增websocket agent module对象
2.对module添加SetUnOnRun接口,设置该接口时不会开启协程执行OnRun
This commit is contained in:
41
sysservice/wsagentservice.go
Normal file
41
sysservice/wsagentservice.go
Normal file
@@ -0,0 +1,41 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user