wrapper used in send

This commit is contained in:
William Banfield
2022-10-20 17:27:57 -04:00
parent 42fc1fc1cc
commit 9742dac312

View File

@@ -261,7 +261,15 @@ func (p *peer) Send(e Envelope) bool {
} else if !p.hasChannel(e.ChannelID) {
return false
}
msgBytes, err := proto.Marshal(e.Message)
msg := e.Message
if w, ok := msg.(Wrapper); ok {
var err error
msg, err = w.Wrap()
if err != nil {
panic(err)
}
}
msgBytes, err := proto.Marshal(msg)
if err != nil {
panic(err) // Q: should this panic or error?
}
@@ -284,7 +292,15 @@ func (p *peer) TrySend(e Envelope) bool {
} else if !p.hasChannel(e.ChannelID) {
return false
}
msgBytes, err := proto.Marshal(e.Message)
msg := e.Message
if w, ok := msg.(Wrapper); ok {
var err error
msg, err = w.Wrap()
if err != nil {
panic(err)
}
}
msgBytes, err := proto.Marshal(msg)
if err != nil {
panic(err)
}