From 963235af51a80e160f1a07a7ca162203c59720ea Mon Sep 17 00:00:00 2001 From: TAT Date: Mon, 10 Mar 2014 10:01:30 +0100 Subject: [PATCH] close #4 --- package.json | 2 +- src/client.js | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 930520f..0fa1f3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plugapi", - "version": "1.1.2", + "version": "1.1.3", "author": "Thomas Andresen ", "description": "Generic API for building plug.dj bots", "contributors": [{ diff --git a/src/client.js b/src/client.js index 648c313..5841f8f 100644 --- a/src/client.js +++ b/src/client.js @@ -8,6 +8,7 @@ var SockJS = require('sockjs-client'), WebSocket = require('ws'), encoder = new Encoder('entity'), util = require('util'), + zlib = require('zlib'), rpcNames = { BOOTH_JOIN: 'booth.join', @@ -226,10 +227,18 @@ function sendGateway(name, args, successCallback, failureCallback) { } function getUpdateCode(callback) { - request('https://d1rfegul30378.cloudfront.net/updatecode.txt', function(err, res, body) { - _updateCode = body; - if (typeof callback === 'function') - callback(); + request({ + url: 'https://d1rfegul30378.cloudfront.net/updatecode.txt', + headers: { + 'Accept-Encoding': 'gzip' + }, + encoding: null + }, function(err, res, body) { + zlib.unzip(body, function(err, data) { + _updateCode = data.toString(); + if (typeof callback === 'function') + callback(); + }); }); } @@ -240,7 +249,7 @@ function joinRoom(name, callback) { DateUtilities.setServerTime(data.serverTime); return sendGateway(rpcNames.ROOM_DETAILS, [name], function(data) { return _this.initRoom(data, function() { - if (callback != null) + if (typeof callback !== 'undefined') return callback(data); }); });