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.

49 lines
905 B
Go

package room
import (
"dcg/game/manager"
pbRoom "dcg/game/pb/room"
"git.noahlan.cn/northlan/ngs/component"
"git.noahlan.cn/northlan/ngs/session"
)
type (
Logic struct {
component.Base
}
)
func NewRoomLogic() *Logic {
return &Logic{}
}
func (m *Logic) CMD() string {
return "room"
}
func (m *Logic) Init() {
}
func (m *Logic) AfterInit() {
session.Lifetime.OnClosed(func(s *session.Session) {
manager.GameManager.RoomManager.SessionLeaveRoom(s)
})
}
func (m *Logic) Shutdown() {
manager.GameManager.RoomManager.Clean()
}
func (m *Logic) Join(s *session.Session, msg *pbRoom.JoinRoomReq) error {
if err := manager.GameManager.RoomManager.SessionJoinRoom(s, msg.GameType, msg.LiveRoomId); err != nil {
return s.Response(&pbRoom.JoinRoomResp{
Code: 500,
Result: "加入房间失败",
})
}
return s.Response(&pbRoom.JoinRoomResp{
Code: 200,
Result: "success",
})
}