Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
close #4
Browse files Browse the repository at this point in the history
  • Loading branch information
TATDK committed Mar 10, 2014
1 parent 52731a6 commit 963235a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugapi",
"version": "1.1.2",
"version": "1.1.3",
"author": "Thomas Andresen <[email protected]>",
"description": "Generic API for building plug.dj bots",
"contributors": [{
Expand Down
19 changes: 14 additions & 5 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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();
});
});
}

Expand All @@ -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);
});
});
Expand Down

0 comments on commit 963235a

Please sign in to comment.