mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
48 lines
1002 B
Go
48 lines
1002 B
Go
package sysservice
|
|
|
|
import (
|
|
"github.com/duanhf2012/origin/network"
|
|
"github.com/duanhf2012/origin/service"
|
|
)
|
|
|
|
type WSServerService struct {
|
|
service.BaseService
|
|
wsserver network.WebsocketServer
|
|
|
|
pattern string
|
|
port uint16
|
|
messageReciver network.IMessageReceiver
|
|
bEnableCompression bool
|
|
}
|
|
|
|
func (ws *WSServerService) OnInit() error {
|
|
|
|
ws.wsserver.Init(ws.port)
|
|
return nil
|
|
}
|
|
|
|
func (ws *WSServerService) OnRun() bool {
|
|
ws.wsserver.Start()
|
|
|
|
return false
|
|
}
|
|
|
|
func NewWSServerService(port uint16) *WSServerService {
|
|
wss := new(WSServerService)
|
|
|
|
wss.port = port
|
|
return wss
|
|
}
|
|
|
|
func (ws *WSServerService) OnDestory() error {
|
|
return nil
|
|
}
|
|
func (ws *WSServerService) SetupReciver(pattern string, messageReciver network.IMessageReceiver, bEnableCompression bool) {
|
|
ws.wsserver.SetupReciver(pattern, messageReciver, bEnableCompression)
|
|
}
|
|
|
|
func (slf *WSServerService) SetWSS(certfile string, keyfile string) bool {
|
|
slf.wsserver.SetWSS(certfile, keyfile)
|
|
return true
|
|
}
|