feat: 添加测试handler,danmaku原样返回。

main
NorthLan 3 years ago
parent 73c0c1a7ae
commit 0cf2f7e5a2

@ -66,6 +66,7 @@ func (l *LiveGameLogic) RegisterNobilityHandler(h NobilityHandlerFunc) {
// HandleDanmaku 弹幕数据处理 // HandleDanmaku 弹幕数据处理
// pushCommonMsg 非弹幕数据是否转发 // pushCommonMsg 非弹幕数据是否转发
func (l *LiveGameLogic) HandleDanmaku(pushCommonMsg bool, user *pbCommon.PbUser, dm *pbMq.MqDanmaku) { func (l *LiveGameLogic) HandleDanmaku(pushCommonMsg bool, user *pbCommon.PbUser, dm *pbMq.MqDanmaku) {
if l.CmdParser != nil {
cmdStruct := l.CmdParser.Parse(dm.Msg) cmdStruct := l.CmdParser.Parse(dm.Msg)
if cmdStruct.IsCMD { if cmdStruct.IsCMD {
for _, m := range cmdStruct.Matches { for _, m := range cmdStruct.Matches {
@ -82,6 +83,17 @@ func (l *LiveGameLogic) HandleDanmaku(pushCommonMsg bool, user *pbCommon.PbUser,
Content: dm.Msg, Content: dm.Msg,
}) })
} }
} else {
room, err := manager.GameManager.RoomByLiveRoomId(dm.LiveRoomId)
if err != nil {
return
}
// 发送正常的非命令弹幕消息
room.Broadcast(pb.PushDanmaku, &pbCommon.DanmakuMsg{
User: user,
Content: dm.Msg,
})
}
} }
func (l *LiveGameLogic) handleCMD(roomId int64, msgId string, prefix string, content []rune, user *pbCommon.PbUser) { func (l *LiveGameLogic) handleCMD(roomId int64, msgId string, prefix string, content []rune, user *pbCommon.PbUser) {

@ -29,6 +29,7 @@ func InitLiveManager(svcCtx *svc.ServiceContext) {
LiveManager.RegisterLogic(NewZhgLiveGameLogic(svcCtx)) LiveManager.RegisterLogic(NewZhgLiveGameLogic(svcCtx))
LiveManager.RegisterLogic(NewZhghzLiveGameLogic().LiveGameLogic) LiveManager.RegisterLogic(NewZhghzLiveGameLogic().LiveGameLogic)
LiveManager.RegisterLogic(NewZhgzdLiveGameLogic(svcCtx)) LiveManager.RegisterLogic(NewZhgzdLiveGameLogic(svcCtx))
LiveManager.RegisterLogic(NewTestLiveGameLogic(svcCtx))
} }
func newManager() *Manager { func newManager() *Manager {

@ -0,0 +1,19 @@
package live_logic
import (
pbRoom "dcg/game/pb/room"
"dcg/game/svc"
)
type TestGameLogic struct {
svcCtx *svc.ServiceContext
*LiveGameLogic
}
func NewTestLiveGameLogic(svcCtx *svc.ServiceContext) *LiveGameLogic {
resp := &TestGameLogic{
svcCtx: svcCtx,
LiveGameLogic: NewLiveGameLogic(pbRoom.GameType_ZHG, nil),
}
return resp.LiveGameLogic
}
Loading…
Cancel
Save