diff --git a/modules/gateway/options.go b/modules/gateway/options.go index 87c1f797a..f042a61cb 100644 --- a/modules/gateway/options.go +++ b/modules/gateway/options.go @@ -14,7 +14,7 @@ type ( } ) -//序列化参数对象 +// LoadConfig 配置文件序列化为Options func (this *Options) LoadConfig(settings map[string]interface{}) (err error) { if settings != nil { err = mapstructure.Decode(settings, this) diff --git a/modules/gateway/wservice_comp.go b/modules/gateway/wservice_comp.go index 0a75bd650..d730369ff 100644 --- a/modules/gateway/wservice_comp.go +++ b/modules/gateway/wservice_comp.go @@ -16,19 +16,24 @@ type WSServiceComp struct { cbase.ModuleCompBase options *Options - module IGateway - gin gin.ISys + module IGateway // 网关 + gin gin.ISys // gin服务接口 } +// Init websocket服务初始化 func (this *WSServiceComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.ModuleCompBase.Init(service, module, comp, options) this.options = options.(*Options) this.module = module.(IGateway) this.gin, err = gin.NewSys(gin.SetListenPort(this.options.ListenPort)) + + // 游戏业务逻辑处理 this.gin.GET("/gateway", this.ws) + return } +// ws 升级websocket连接处理本次请求 func (this *WSServiceComp) ws(c *engine.Context) { upGrader := websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool {