mirror of
https://github.com/logos-messaging/logos-messaging-go-bindings.git
synced 2026-01-04 06:53:11 +00:00
Merge remote-tracking branch 'origin/master' into Fix_store_format
This commit is contained in:
commit
ab317903ec
@ -31,27 +31,27 @@ type wakuEnvelope struct {
|
|||||||
MessageHash MessageHash `json:"messageHash"`
|
MessageHash MessageHash `json:"messageHash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEnvelope creates a new Envelope from a json string generated in nwaku
|
// UnmarshalJSON implements the json.Unmarshaler interface
|
||||||
func NewEnvelope(jsonEventStr string) (*Envelope, error) {
|
func (e *Envelope) UnmarshalJSON(input []byte) error {
|
||||||
wakuEnvelope := wakuEnvelope{}
|
wakuEnvelope := wakuEnvelope{}
|
||||||
err := json.Unmarshal([]byte(jsonEventStr), &wakuEnvelope)
|
err := json.Unmarshal(input, &wakuEnvelope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Envelope{
|
e.msg = &pb.WakuMessage{
|
||||||
msg: &pb.WakuMessage{
|
Payload: wakuEnvelope.WakuMessage.Payload,
|
||||||
Payload: wakuEnvelope.WakuMessage.Payload,
|
ContentTopic: wakuEnvelope.WakuMessage.ContentTopic,
|
||||||
ContentTopic: wakuEnvelope.WakuMessage.ContentTopic,
|
Version: wakuEnvelope.WakuMessage.Version,
|
||||||
Version: wakuEnvelope.WakuMessage.Version,
|
Timestamp: wakuEnvelope.WakuMessage.Timestamp,
|
||||||
Timestamp: wakuEnvelope.WakuMessage.Timestamp,
|
Meta: wakuEnvelope.WakuMessage.Meta,
|
||||||
Meta: wakuEnvelope.WakuMessage.Meta,
|
Ephemeral: wakuEnvelope.WakuMessage.Ephemeral,
|
||||||
Ephemeral: wakuEnvelope.WakuMessage.Ephemeral,
|
RateLimitProof: wakuEnvelope.WakuMessage.RateLimitProof,
|
||||||
RateLimitProof: wakuEnvelope.WakuMessage.RateLimitProof,
|
}
|
||||||
},
|
e.topic = wakuEnvelope.PubsubTopic
|
||||||
topic: wakuEnvelope.PubsubTopic,
|
e.hash = wakuEnvelope.MessageHash
|
||||||
hash: wakuEnvelope.MessageHash,
|
|
||||||
}, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Envelope) Message() *pb.WakuMessage {
|
func (e *Envelope) Message() *pb.WakuMessage {
|
||||||
|
|||||||
@ -480,12 +480,14 @@ func (n *WakuNode) OnEvent(eventStr string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *WakuNode) parseMessageEvent(eventStr string) {
|
func (n *WakuNode) parseMessageEvent(eventStr string) {
|
||||||
envelope, err := common.NewEnvelope(eventStr)
|
var envelope common.Envelope
|
||||||
|
err := json.Unmarshal([]byte(eventStr), &envelope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error("could not parse message %v", err)
|
Error("could not parse message %v", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case n.MsgChan <- *envelope:
|
case n.MsgChan <- envelope:
|
||||||
default:
|
default:
|
||||||
Warn("Can't deliver message to subscription, MsgChan is full")
|
Warn("Can't deliver message to subscription, MsgChan is full")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user