Commit ce98f31 1 parent c13b461 commit ce98f31 Copy full SHA for ce98f31
File tree 3 files changed +19
-10
lines changed
3 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 11
11
12
12
## js-ipfs
13
13
14
- This package has been tested with js-ipfs version __ 0.28.0 __ .
14
+ This package has been tested with js-ipfs version __ 0.29.1 __ .
15
15
16
16
## Install
17
17
@@ -77,7 +77,7 @@ Broacasts message (string or buffer).
77
77
78
78
Sends message (string or buffer) to peer.
79
79
80
- ## room.leave()
80
+ ## async room.leave()
81
81
82
82
Leaves room, stopping everything.
83
83
Original file line number Diff line number Diff line change 38
38
"chai" : " ^4.1.1" ,
39
39
"dirty-chai" : " ^2.0.1" ,
40
40
"aegir" : " ^12.1.3" ,
41
- "ipfs" : " ~0.28.0 "
41
+ "ipfs" : " ~0.29.1 "
42
42
},
43
43
"browser" : {
44
44
"./test/utils/create-repo-node.js" : " ./test/utils/create-repo-browser.js"
Original file line number Diff line number Diff line change @@ -52,12 +52,15 @@ class PubSubRoom extends EventEmitter {
52
52
}
53
53
54
54
leave ( ) {
55
- timers . clearInterval ( this . _interval )
56
- Object . keys ( this . _connections ) . forEach ( ( peer ) => {
57
- this . _connections [ peer ] . stop ( )
55
+ return new Promise ( ( resolve , reject ) => {
56
+ timers . clearInterval ( this . _interval )
57
+ Object . keys ( this . _connections ) . forEach ( ( peer ) => {
58
+ this . _connections [ peer ] . stop ( )
59
+ } )
60
+ directConnection . emitter . removeListener ( this . _topic , this . _handleDirectMessage )
61
+ this . once ( 'stopped' , ( ) => resolve ( ) )
62
+ this . emit ( 'stopping' )
58
63
} )
59
- directConnection . emitter . removeListener ( this . _topic , this . _handleDirectMessage )
60
- this . emit ( 'stop' )
61
64
}
62
65
63
66
broadcast ( _message ) {
@@ -117,8 +120,14 @@ class PubSubRoom extends EventEmitter {
117
120
}
118
121
} )
119
122
120
- this . once ( 'stop' , ( ) => {
121
- this . _ipfs . pubsub . unsubscribe ( this . _topic , listener )
123
+ this . once ( 'stopping' , ( ) => {
124
+ this . _ipfs . pubsub . unsubscribe ( this . _topic , listener , ( err ) => {
125
+ if ( err ) {
126
+ this . emit ( 'error' , err )
127
+ } else {
128
+ this . emit ( 'stopped' )
129
+ }
130
+ } )
122
131
} )
123
132
124
133
this . _ipfs . _libp2pNode . handle ( PROTOCOL , directConnection . handler )
You can’t perform that action at this time.
0 commit comments