mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-29 18:55:40 -05:00
Set no delay on stream if it's TCP. Fixes #38
This commit is contained in:
parent
33e9c39af6
commit
baaac91055
1 changed files with 5 additions and 3 deletions
|
@ -75,6 +75,8 @@ Client.prototype.onRaw = function(type, func) {
|
|||
Client.prototype.setSocket = function(socket) {
|
||||
var self = this;
|
||||
self.socket = socket;
|
||||
if (self.socket.setNoDelay)
|
||||
self.socket.setNoDelay(true);
|
||||
var incomingBuffer = new Buffer(0);
|
||||
self.socket.on('data', function(data) {
|
||||
if (self.encryptionEnabled) data = new Buffer(self.decipher.update(data), 'binary');
|
||||
|
@ -128,7 +130,7 @@ Client.prototype.connect = function(port, host) {
|
|||
var self = this;
|
||||
if (port == 25565) {
|
||||
dns.resolveSrv("_minecraft._tcp." + host, function(err, addresses) {
|
||||
if (addresses) {
|
||||
if (addresses && addresses.length > 0) {
|
||||
self.setSocket(net.connect(addresses[0].port, addresses[0].name));
|
||||
} else {
|
||||
self.setSocket(net.connect(port, host));
|
||||
|
|
Loading…
Reference in a new issue