You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
761 B
Go

package svc
import (
"dcg/app/user_center/usercenter"
"dcg/config"
"dcg/game/room"
"git.noahlan.cn/northlan/ngs/component"
"github.com/zeromicro/go-zero/zrpc"
"strings"
)
type ServiceContext struct {
Services *component.Components
RoomManager *room.Manager
UserCenterRpc usercenter.UserCenter
}
func NewServiceContext() *ServiceContext {
services := &component.Components{}
roomManager := room.NewRoomManager()
services.Register(roomManager,
component.WithName("room"),
component.WithNameFunc(func(s string) string {
return strings.ToLower(s)
}))
return &ServiceContext{
Services: services,
RoomManager: roomManager,
// rpc
UserCenterRpc: usercenter.NewUserCenter(zrpc.MustNewClient(config.Config.UserCenterRpc)),
}
}