domain/channel.js
function Channel(client, id){
  EE.call(this);
  this.client = client;
  this.id = id;
  this.opened = false;
  this.confirmMode = false;
  var work = (id, method, err) => {
    this.opened = false;
    var error = new RabbitClientError(err);
    this.emit('close', error, this.id);
    if (error) {
      this.emit('error', error);
      this.client.channel['close-ok'](this.id, (err) => {
        if (err) this.emit('error', err);
      });
    }
  };
  var returning = (id, method, err) => {
    var error = new RabbitRouteError(err);
    this.emit('return', error, this.id);
    if (error) {
      this.emit('error', error);
    }
  };
  this.client.once(this.id+':channel.close', work);
  this.once('close', ()=>{
    this.client.removeListener(this.id+':channel.close', work);
    this.client.removeListener(this.id+':basic.return', returning);
  });
  this.client.on(this.id+':basic.return', returning);
}
function Channel(client, id){
  EE.call(this);
  this.client = client;
  this.id = id;
  this.opened = false;
  this.confirmMode = false;
  var work = (id, method, err) => {
    this.opened = false;
    var error = new RabbitClientError(err);
    this.emit('close', error, this.id);
    if (error) {
      this.emit('error', error);
      this.client.channel['close-ok'](this.id, (err) => {
        if (err) this.emit('error', err);
      });
    }
  };
  var returning = (id, method, err) => {
    var error = new RabbitRouteError(err);
    this.emit('return', error, this.id);
    if (error) {
      this.emit('error', error);
    }
  };
  this.client.once(this.id+':channel.close', work);
  this.once('close', ()=>{
    this.client.removeListener(this.id+':channel.close', work);
    this.client.removeListener(this.id+':basic.return', returning);
  });
  this.client.on(this.id+':basic.return', returning);
}
function Channel ( client , id ) { EE . call ( this ) ; this . client = client ; this . id = id ; this . opened = false ; this . confirmMode = false ; var work = ( id , method , err ) => { this . opened = false ; var error = new RabbitClientError ( err ) ; this . emit ( 'close' , error , this . id ) ; if ( error ) { this . emit ( 'error' , error ) ; this . client . channel [ 'close-ok' ] ( this . id , ( err ) => { if ( err ) this . emit ( 'error' , err ) ; } ) ; } } ; var returning = ( id , method , err ) => { var error = new RabbitRouteError ( err ) ; this . emit ( 'return' , error , this . id ) ; if ( error ) { this . emit ( 'error' , error ) ; } } ; this . client . once ( this . id + ':channel.close' , work ) ; this . once ( 'close' , ( ) => { this . client . removeListener ( this . id + ':channel.close' , work ) ; this . client . removeListener ( this . id + ':basic.return' , returning ) ; } ) ; this . client . on ( this . id + ':basic.return' , returning ) ; }
Work with channels.

The channel class provides methods for a client to establish a channel to a server
and for both peers to operate the channel thereafter.

@class Channel
@extends EventEmitter
@param {BRAMQPClient} client Client object that returns from bramqp#openAMQPCommunication() method.
@param {Number} id Channel id.
@return {Channel}
@constructor
Work with channels .