@@ -74,7 +74,7 @@ class MessageBus extends EventEmitter {
7474
7575 /**
7676 * The unique name of the bus connection. This will be `null` until the
77- * `MessageBus` is connected.
77+ * `MessageBus` is connected, unless we're operating in peer-to-peer mode .
7878 * @memberof MessageBus#
7979 * @member {string} name
8080 */
@@ -159,22 +159,28 @@ class MessageBus extends EventEmitter {
159159 this . emit ( 'error' , err ) ;
160160 } ) ;
161161
162- const helloMessage = new Message ( {
163- path : '/org/freedesktop/DBus' ,
164- destination : 'org.freedesktop.DBus' ,
165- interface : 'org.freedesktop.DBus' ,
166- member : 'Hello'
167- } ) ;
168-
169- this . call ( helloMessage )
170- . then ( ( msg ) => {
171- this . name = msg . body [ 0 ] ;
162+ if ( conn . mode === 'p2p' ) {
163+ process . nextTick ( ( ) => {
172164 this . emit ( 'connect' ) ;
173- } )
174- . catch ( ( err ) => {
175- this . emit ( 'error' , err ) ;
176- throw new Error ( err ) ;
177165 } ) ;
166+ } else {
167+ const helloMessage = new Message ( {
168+ path : '/org/freedesktop/DBus' ,
169+ destination : 'org.freedesktop.DBus' ,
170+ interface : 'org.freedesktop.DBus' ,
171+ member : 'Hello'
172+ } ) ;
173+
174+ this . call ( helloMessage )
175+ . then ( ( msg ) => {
176+ this . name = msg . body [ 0 ] ;
177+ this . emit ( 'connect' ) ;
178+ } )
179+ . catch ( ( err ) => {
180+ this . emit ( 'error' , err ) ;
181+ throw new Error ( err ) ;
182+ } ) ;
183+ }
178184 }
179185
180186 /**
@@ -468,6 +474,10 @@ class MessageBus extends EventEmitter {
468474
469475 this . _matchRules [ match ] = 1 ;
470476
477+ if ( this . _connection . mode === 'p2p' ) {
478+ return Promise . resolve ( ) ;
479+ }
480+
471481 // TODO catch error and update refcount
472482 const msg = new Message ( {
473483 path : '/org/freedesktop/DBus' ,
@@ -496,6 +506,10 @@ class MessageBus extends EventEmitter {
496506
497507 delete this . _matchRules [ match ] ;
498508
509+ if ( this . _connection . mode === 'p2p' ) {
510+ return Promise . resolve ( ) ;
511+ }
512+
499513 // TODO catch error and update refcount
500514 const msg = new Message ( {
501515 path : '/org/freedesktop/DBus' ,
0 commit comments