From 023e6030083283f37350f78be7a9772969077dac Mon Sep 17 00:00:00 2001 From: John Southworth Date: Sun, 17 Sep 2017 15:54:34 -0700 Subject: [PATCH] Expose the default handlers This allows an implementation to reuse one of the implementations if they would like to implement a replacement for the other. --- conn.go | 4 ++-- default_handler.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/conn.go b/conn.go index 3880dde9..5720e2eb 100644 --- a/conn.go +++ b/conn.go @@ -160,7 +160,7 @@ func Dial(address string) (*Conn, error) { if err != nil { return nil, err } - return newConn(tr, newDefaultHandler(), newDefaultSignalHandler()) + return newConn(tr, NewDefaultHandler(), NewDefaultSignalHandler()) } // DialHandler establishes a new private connection to the message bus specified by address, using the supplied handlers. @@ -174,7 +174,7 @@ func DialHandler(address string, handler Handler, signalHandler SignalHandler) ( // NewConn creates a new private *Conn from an already established connection. func NewConn(conn io.ReadWriteCloser) (*Conn, error) { - return NewConnHandler(conn, newDefaultHandler(), newDefaultSignalHandler()) + return NewConnHandler(conn, NewDefaultHandler(), NewDefaultSignalHandler()) } // NewConnHandler creates a new private *Conn from an already established connection, using the supplied handlers. diff --git a/default_handler.go b/default_handler.go index 8a0091dd..e81f73ac 100644 --- a/default_handler.go +++ b/default_handler.go @@ -18,7 +18,10 @@ func newIntrospectIntf(h *defaultHandler) *exportedIntf { return newExportedIntf(methods, true) } -func newDefaultHandler() *defaultHandler { +//NewDefaultHandler returns an instance of the default +//call handler. This is useful if you want to implement only +//one of the two handlers but not both. +func NewDefaultHandler() *defaultHandler { h := &defaultHandler{ objects: make(map[ObjectPath]*exportedObj), defaultIntf: make(map[string]*exportedIntf), @@ -214,7 +217,10 @@ func (obj *exportedIntf) isFallbackInterface() bool { return obj.includeSubtree } -func newDefaultSignalHandler() *defaultSignalHandler { +//NewDefaultSignalHandler returns an instance of the default +//signal handler. This is useful if you want to implement only +//one of the two handlers but not both. +func NewDefaultSignalHandler() *defaultSignalHandler { return &defaultSignalHandler{} }