fox/ipb/helper.go

35 lines
812 B
Go
Raw Permalink Normal View History

2025-05-29 11:49:24 +08:00
package ipb
2025-06-07 12:13:12 +08:00
import (
"encoding/json"
"github.com/golang/protobuf/proto"
)
2025-06-02 21:37:23 +08:00
2025-06-07 12:13:12 +08:00
func MakeMsg(serviceName string, connId uint32, userId int64, msgId int32, data []byte) *InternalMsg {
2025-05-29 11:49:24 +08:00
return &InternalMsg{
ServiceName: serviceName,
ConnId: connId,
UserId: userId,
MsgId: msgId,
2025-06-07 12:13:12 +08:00
Msg: data,
2025-05-29 11:49:24 +08:00
}
}
2025-06-07 12:13:12 +08:00
func MakeMsgEx(serviceName string, connId uint32, userId int64, msgId int32, msg proto.Message) *InternalMsg {
data, _ := proto.Marshal(msg)
return MakeMsg(serviceName, connId, userId, msgId, data)
}
2025-06-14 13:32:07 +08:00
func MakeRpcMsg(rpcMsgId string, userId int64, msg any) *InternalMsg {
2025-06-02 21:37:23 +08:00
data, _ := json.Marshal(msg)
return &InternalMsg{
ServiceName: "",
ConnId: 0,
UserId: userId,
MsgId: 0,
Msg: data,
Type: MsgType_RpcMsg,
RpcMsgId: rpcMsgId,
}
}