27 lines
572 B
Go
27 lines
572 B
Go
package ipb
|
|
|
|
import "encoding/json"
|
|
|
|
func MakeMsg(serviceName string, connId uint32, userId int64, msgId int32, msg []byte) *InternalMsg {
|
|
return &InternalMsg{
|
|
ServiceName: serviceName,
|
|
ConnId: connId,
|
|
UserId: userId,
|
|
MsgId: msgId,
|
|
Msg: msg,
|
|
}
|
|
}
|
|
|
|
func MakeRpcMsg[T any](rpcMsgId string, userId int64, msg *T) *InternalMsg {
|
|
data, _ := json.Marshal(msg)
|
|
return &InternalMsg{
|
|
ServiceName: "",
|
|
ConnId: 0,
|
|
UserId: userId,
|
|
MsgId: 0,
|
|
Msg: data,
|
|
Type: MsgType_RpcMsg,
|
|
RpcMsgId: rpcMsgId,
|
|
}
|
|
}
|