lib/server.js
function MongolianServer(mongolian, url) {
    var self = this
    this.mongolian = mongolian
    this.url = url
    this._callbacks = []
    this._callbackCount = 0
    this._connection = taxman(function(callback) {
        var connection = new Connection
        var connected = false
        connection.requestId = 0
        connection.on('error', function(error) {
            mongolian.log.error(self+": "+require('util').inspect(error))
            if (!connected) callback(error)
            self.close(error)
        })
        connection.on('close', function() {
            mongolian.log.debug(self+": Disconnected")
            self.close()
        })
        connection.on('connect',function() {
            mongolian.log.debug(self+": Connected")
            connected = true
            callback(null, connection)
        })
        connection.on('message', function(message) {
            var response = new mongo.Response(message)
//            mongolian.log.debug("<<<--- "+require('util').inspect(response,undefined,5,true).slice(0,5000))
            var cb = self._callbacks[response.responseTo]
            if (cb) {
                delete self._callbacks[response.responseTo]
                self._callbackCount--
                cb(null,response)
            }
        })
        connection.connect(url.port, url.host)
    })

}
function MongolianServer(mongolian, url) {
    var self = this
    this.mongolian = mongolian
    this.url = url
    this._callbacks = []
    this._callbackCount = 0
    this._connection = taxman(function(callback) {
        var connection = new Connection
        var connected = false
        connection.requestId = 0
        connection.on('error', function(error) {
            mongolian.log.error(self+": "+require('util').inspect(error))
            if (!connected) callback(error)
            self.close(error)
        })
        connection.on('close', function() {
            mongolian.log.debug(self+": Disconnected")
            self.close()
        })
        connection.on('connect',function() {
            mongolian.log.debug(self+": Connected")
            connected = true
            callback(null, connection)
        })
        connection.on('message', function(message) {
            var response = new mongo.Response(message)
//            mongolian.log.debug("<<<--- "+require('util').inspect(response,undefined,5,true).slice(0,5000))
            var cb = self._callbacks[response.responseTo]
            if (cb) {
                delete self._callbacks[response.responseTo]
                self._callbackCount--
                cb(null,response)
            }
        })
        connection.connect(url.port, url.host)
    })

}
function MongolianServer ( mongolian , url ) { var self = this this . mongolian = mongolian this . url = url this . _callbacks = [ ] this . _callbackCount = 0 this . _connection = taxman ( function ( callback ) { var connection = new Connection var connected = false connection . requestId = 0 connection . on ( 'error' , function ( error ) { mongolian . log . error ( self + ": " + require ( 'util' ) . inspect ( error ) ) if ( ! connected ) callback ( error ) self . close ( error ) } ) connection . on ( 'close' , function ( ) { mongolian . log . debug ( self + ": Disconnected" ) self . close ( ) } ) connection . on ( 'connect' , function ( ) { mongolian . log . debug ( self + ": Connected" ) connected = true callback ( null , connection ) } ) connection . on ( 'message' , function ( message ) { var response = new mongo . Response ( message ) //            mongolian.log.debug("<<<--- "+require('util').inspect(response,undefined,5,true).slice(0,5000)) var cb = self . _callbacks [ response . responseTo ] if ( cb ) { delete self . _callbacks [ response . responseTo ] self . _callbackCount -- cb ( null , response ) } } ) connection . connect ( url . port , url . host ) } ) }
Constructs a new MongolianServer object
Constructs a new MongolianServer object