35 lines
812 B
Go
35 lines
812 B
Go
package ipb
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/golang/protobuf/proto"
|
|
)
|
|
|
|
func MakeMsg(serviceName string, connId uint32, userId int64, msgId int32, data []byte) *InternalMsg {
|
|
return &InternalMsg{
|
|
ServiceName: serviceName,
|
|
ConnId: connId,
|
|
UserId: userId,
|
|
MsgId: msgId,
|
|
Msg: data,
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
func MakeRpcMsg(rpcMsgId string, userId int64, msg any) *InternalMsg {
|
|
data, _ := json.Marshal(msg)
|
|
return &InternalMsg{
|
|
ServiceName: "",
|
|
ConnId: 0,
|
|
UserId: userId,
|
|
MsgId: 0,
|
|
Msg: data,
|
|
Type: MsgType_RpcMsg,
|
|
RpcMsgId: rpcMsgId,
|
|
}
|
|
}
|