service/app/firenze/controller/websocket.go

61 lines
1.5 KiB
Go

package controller
import (
"github.com/gin-gonic/gin"
firenzeproto "service/api/proto/firenze"
"service/app/firenze/service"
"service/library/logger"
)
func WsHandler(ctx *gin.Context) {
err := service.DefaultService.HandleWsRequest(ctx)
if err != nil {
logger.Error("HandleWsRequest fail, err: %v", err)
ReplyErrorMsg(ctx, err.Error())
}
}
func SendBizMsgHandler(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*firenzeproto.SendBizMsgParam)
err := service.DefaultService.SendBizMsg(ctx, req)
if err != nil {
logger.Error("SendBizMsg fail, req: %v, err: %v", err)
ReplyErrorMsg(ctx, err.Error())
return
}
ReplyOk(ctx, nil)
}
func LiveMidsHandler(ctx *gin.Context) {
ReplyOk(ctx, service.DefaultService.LiveMids())
}
func OnlineMidsHandler(ctx *gin.Context) {
data := firenzeproto.OnlineMidsData{
Mids: service.DefaultService.LiveMids(),
}
ReplyOk(ctx, data)
}
func BatchSendBizMsgHandler(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*firenzeproto.BatchSendBizMsgParam)
err := service.DefaultService.BatchSendBizMsg(ctx, req)
if err != nil {
logger.Error("SendBizMsg fail, req: %v, err: %v", err)
ReplyErrorMsg(ctx, err.Error())
return
}
ReplyOk(ctx, nil)
}
func SendBroadMsgHandler(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*firenzeproto.SendBroadcastMsgParam)
err := service.DefaultService.SendBroadcastMsg(ctx, req)
if err != nil {
logger.Error("SendBroadcastMsg fail, req: %v, err: %v", err)
ReplyErrorMsg(ctx, err.Error())
return
}
ReplyOk(ctx, nil)
}