The Best Kept Secret in the JDK - VisualVM

less than 1 minute read

We recently started up a new game of VGAPlanets and upon discovering the api I thought it would be fun, and a learning experience to create a hubot-script to access game information.

hubot runs on node.js and is written in CoffeeScript. VGAPlanets returns all data as gzip compressed. Finding any information on how to handle

(https://gist.github.com/2669898#gistcomment-316296)

var http = require('http');
var options = { 
  host: 'api.planets.nu', 
  port: 80, 
  path: '/game/loadinfo?gameid=815',
  headers: {
    "Accept-Encoding": "gzip"
  }
};

var zlib = require('zlib');

http.get(options, function(res) {
  var gunzip = zlib.createGunzip();
  res.pipe(gunzip);
  gunzip.on('data', function(data) {
    console.log(data.toString());
  });
}).on('error', function(e) { console.log('error ' + e); });

snipt.net