diff --git a/src/client.js b/src/client.js index c4628c3..35fdca1 100644 --- a/src/client.js +++ b/src/client.js @@ -1,8 +1,6 @@ -var net = require('net') - , EventEmitter = require('events').EventEmitter +var EventEmitter = require('events').EventEmitter , util = require('util') , protocol = require('./protocol') - , dns = require('dns') , createPacketBuffer = protocol.createPacketBuffer , compressPacketBuffer = protocol.compressPacketBuffer , oldStylePacket = protocol.oldStylePacket @@ -152,21 +150,6 @@ Client.prototype.setSocket = function(socket) { } }; -Client.prototype.connect = function(port, host) { - var self = this; - if (port == 25565 && net.isIP(host) === 0) { - dns.resolveSrv("_minecraft._tcp." + host, function(err, addresses) { - if (addresses && addresses.length > 0) { - self.setSocket(net.connect(addresses[0].port, addresses[0].name)); - } else { - self.setSocket(net.connect(port, host)); - } - }); - } else { - self.setSocket(net.connect(port, host)); - } -}; - Client.prototype.end = function(reason) { this._endReason = reason; this.socket.end(); diff --git a/src/index.js b/src/index.js index 557e7f9..9e853ad 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,8 @@ var EventEmitter = require('events').EventEmitter , superagent = require('superagent') , protocol = require('./protocol') , Client = require('./client') + , dns = require('dns') + , net = require('net') , Server = require('./server') , Yggdrasil = require('./yggdrasil.js') , getSession = Yggdrasil.getSession @@ -228,6 +230,21 @@ function createServer(options) { return server; } +Client.prototype.connect = function(port, host) { + var self = this; + if (port == 25565 && net.isIP(host) === 0) { + dns.resolveSrv("_minecraft._tcp." + host, function(err, addresses) { + if (addresses && addresses.length > 0) { + self.setSocket(net.connect(addresses[0].port, addresses[0].name)); + } else { + self.setSocket(net.connect(port, host)); + } + }); + } else { + self.setSocket(net.connect(port, host)); + } +}; + function createClient(options) { assert.ok(options, "options is required"); var port = options.port || 25565;