mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
新增项目名称
This commit is contained in:
@@ -30,7 +30,3 @@ func (slf *HttpServer) startListen() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (slf *WebsocketServer) Stop() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type IService interface {
|
|||||||
OnInit() error
|
OnInit() error
|
||||||
OnEndInit() error
|
OnEndInit() error
|
||||||
OnRun() error
|
OnRun() error
|
||||||
|
OnRunLoop() error
|
||||||
OnDestory() error
|
OnDestory() error
|
||||||
OnFetchService(iservice IService) error
|
OnFetchService(iservice IService) error
|
||||||
GetServiceType() int
|
GetServiceType() int
|
||||||
@@ -120,8 +121,13 @@ func (slf *BaseService) Init(Iservice interface{}, servicetype int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (slf *BaseService) OnRunLoop() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (slf *BaseService) Run(service IService, exit chan bool, pwaitGroup *sync.WaitGroup) error {
|
func (slf *BaseService) Run(service IService, exit chan bool, pwaitGroup *sync.WaitGroup) error {
|
||||||
defer pwaitGroup.Done()
|
defer pwaitGroup.Done()
|
||||||
|
service.OnRun()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-exit:
|
case <-exit:
|
||||||
@@ -130,7 +136,7 @@ func (slf *BaseService) Run(service IService, exit chan bool, pwaitGroup *sync.W
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
slf.tickTime = time.Now().UnixNano() / 1e6
|
slf.tickTime = time.Now().UnixNano() / 1e6
|
||||||
service.OnRun()
|
service.OnRunLoop()
|
||||||
slf.tickTime = time.Now().UnixNano() / 1e6
|
slf.tickTime = time.Now().UnixNano() / 1e6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
43
sysservice/websocketservice.go
Normal file
43
sysservice/websocketservice.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
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.pattern, ws.port, ws.messageReciver, ws.bEnableCompression)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ws *WSServerService) OnRun() error {
|
||||||
|
ws.wsserver.Start()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWSServerService(pattern string, port uint16, messageReciver network.IMessageReceiver, bEnableCompression bool) *WSServerService {
|
||||||
|
wss := new(WSServerService)
|
||||||
|
wss.pattern = pattern
|
||||||
|
wss.port = port
|
||||||
|
wss.messageReciver = messageReciver
|
||||||
|
wss.bEnableCompression = bEnableCompression
|
||||||
|
|
||||||
|
wss.Init(wss, 0)
|
||||||
|
return wss
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ws *WSServerService) OnDestory() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user