@@ -161,8 +161,7 @@ PubSocket.prototype.connect = function(destination, callback) {
161161 var self = this , ch = this . ch ;
162162 ch . assertExchange ( destination ,
163163 this . options . routing || 'fanout' ,
164- { durable : false ,
165- autoDelete : true } )
164+ { durable : false , autoDelete : false } )
166165 . then ( function ( ok ) {
167166 self . pubs . push ( destination ) ;
168167 } ) . then ( callback || ignore ) ;
@@ -216,29 +215,22 @@ function SubSocket(channel, opts) {
216215inherits ( SubSocket , Readable ) ;
217216addSocketMethods ( SubSocket ) ;
218217
219- SubSocket . prototype . connect = function ( source , callback ) {
218+ SubSocket . prototype . connect = function ( source , topic , callback ) {
219+ // Support the general form of connect
220+ if ( callback === undefined && typeof topic === 'function' ) {
221+ callback = topic ;
222+ topic = '' ;
223+ }
220224 var ch = this . ch , queue = this . queue , self = this ;
221225 ch . assertExchange ( source ,
222226 this . options . routing || 'fanout' ,
223- { autoDelete : true } )
227+ { durable : false , autoDelete : false } )
224228 . then ( function ( ok ) {
225- self . subs . push ( source ) ;
226- self . patterns . forEach ( function ( pat ) {
227- ch . bindQueue ( queue , source , pat ) ;
228- } ) ;
229+ return ch . bindQueue ( queue , source , topic ) ;
229230 } )
230231 . then ( callback || ignore ) ;
231232} ;
232233
233- SubSocket . prototype . subscribe = function ( pattern ) {
234- var ch = this . ch ; queue = this . queue ;
235- pattern = pattern || '' ;
236- this . subs . forEach ( function ( sub ) {
237- ch . bindQueue ( queue , sub , pattern ) ;
238- } ) ;
239- this . patterns . push ( pattern ) ;
240- } ;
241-
242234// AMQP and the stream API don't really work well together here. I'm
243235// supposed to initiate reads when this method is called, then not
244236// push any more once I get `false` back from `#push`; but how do I do
0 commit comments