Skip to content

Commit

Permalink
Destintion and Sender are optional fields, handle that
Browse files Browse the repository at this point in the history
This is not typically the case for bus-uses, but is common when
using custom peer-to-peer connections.
  • Loading branch information
alexlarsson committed Mar 27, 2014
1 parent da6051a commit 319d3b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,9 @@ func (conn *Conn) sendError(e Error, dest string, serial uint32) {
msg.Type = TypeError
msg.serial = conn.getSerial()
msg.Headers = make(map[HeaderField]Variant)
msg.Headers[FieldDestination] = MakeVariant(dest)
if dest != "" {
msg.Headers[FieldDestination] = MakeVariant(dest)
}
msg.Headers[FieldErrorName] = MakeVariant(e.Name)
msg.Headers[FieldReplySerial] = MakeVariant(serial)
msg.Body = e.Body
Expand All @@ -460,7 +462,9 @@ func (conn *Conn) sendReply(dest string, serial uint32, values ...interface{}) {
msg.Type = TypeMethodReply
msg.serial = conn.getSerial()
msg.Headers = make(map[HeaderField]Variant)
msg.Headers[FieldDestination] = MakeVariant(dest)
if dest != "" {
msg.Headers[FieldDestination] = MakeVariant(dest)
}
msg.Headers[FieldReplySerial] = MakeVariant(serial)
msg.Body = values
if len(values) > 0 {
Expand Down
6 changes: 4 additions & 2 deletions export.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (conn *Conn) handleCall(msg *Message) {
name := msg.Headers[FieldMember].value.(string)
path := msg.Headers[FieldPath].value.(ObjectPath)
ifaceName, hasIface := msg.Headers[FieldInterface].value.(string)
sender := msg.Headers[FieldSender].value.(string)
sender, hasSender := msg.Headers[FieldSender].value.(string)
serial := msg.serial
if ifaceName == "org.freedesktop.DBus.Peer" {
switch name {
Expand Down Expand Up @@ -132,7 +132,9 @@ func (conn *Conn) handleCall(msg *Message) {
reply.Type = TypeMethodReply
reply.serial = conn.getSerial()
reply.Headers = make(map[HeaderField]Variant)
reply.Headers[FieldDestination] = msg.Headers[FieldSender]
if hasSender {
reply.Headers[FieldDestination] = msg.Headers[FieldSender]
}
reply.Headers[FieldReplySerial] = MakeVariant(msg.serial)
reply.Body = make([]interface{}, len(ret)-1)
for i := 0; i < len(ret)-1; i++ {
Expand Down

0 comments on commit 319d3b8

Please sign in to comment.