mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-14 15:54:42 +08:00
优化初始化方式
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package GateService
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/duanhf2012/origin/event"
|
||||
"github.com/duanhf2012/origin/network"
|
||||
"github.com/duanhf2012/origin/network/processor"
|
||||
@@ -37,10 +38,10 @@ func (slf *GateService) OnEventHandler(ev *event.Event) error{
|
||||
}
|
||||
|
||||
func (slf *GateService) OnConnected(clientid uint64){
|
||||
|
||||
fmt.Printf("client id %d connected",clientid)
|
||||
}
|
||||
|
||||
|
||||
func (slf *GateService) OnDisconnected(clientid uint64){
|
||||
|
||||
fmt.Printf("client id %d disconnected",clientid)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"ListenAddr":"127.0.0.1:8001",
|
||||
"NodeName": "Node_Test1",
|
||||
"remark":"//以_打头的,表示只在本机进程,不对整个子网开发",
|
||||
"ServiceList": ["TestService1","TestService2","TestServiceCall"]
|
||||
"ServiceList": ["TestService1","TestService2","TestServiceCall","GateService","TcpService"]
|
||||
},
|
||||
{
|
||||
"NodeId": 2,
|
||||
|
||||
@@ -189,12 +189,11 @@ func (slf *TestService2) OnInit() error {
|
||||
}
|
||||
|
||||
func main(){
|
||||
node.Init()
|
||||
tcpService := &sysservice.TcpService{}
|
||||
gateService := &GateService.GateService{}
|
||||
|
||||
tcpService.SetEventReciver(gateService)
|
||||
node.Setup(tcpService,gateService)
|
||||
node.Init()
|
||||
|
||||
node.Start()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user