Skip to content

Instantly share code, notes, and snippets.

View rjriel's full-sized avatar

Rey Riel rjriel

View GitHub Profile
let getGame = (gameId) => {
return new Promise((resolve, reject) => {
// we want to perform a GET request to the games/:id API
// to retrieve information about the given game
let options = createOptions(`games/${gameId}`, "GET")
request.get(options, (error, res, body) => {
if (error || res.statusCode !== 200) {
console.error("Error Getting Game", error || res.body)
@rjriel
rjriel / index.js
Last active October 27, 2016 15:07
CREATE OPTIONS FUNCTION
// This is the api key passed to the Qritter Wars REST API in the Authorization header
// for authentication
// format: base64 encoded value of <apiId>:<apiSecret>
const apiKey = new Buffer(`${config.apiId}:${config.apiSecret}`).toString('base64')
let createOptions = (endpoint, method, body) => {
// we need to return all options that the request module expects
// for an http request. 'uri' is the location of the request, 'method'
// is what http method we want to use (most likely GET or POST). headers
// are the http headers we want attached to our request
@rjriel
rjriel / config.js
Last active October 27, 2016 14:45
socket io connect with arguments
module.exports = {
host: "qlikathon.qlik.com",
socketPort: 3000,
apiPort: 8080,
apiId: "<id>",
apiSecret: "<secret>"
}
@rjriel
rjriel / index.js
Created October 27, 2016 14:15
getting started
console.log("Welcome to the Qritter Wars Client")
@rjriel
rjriel / client.js
Last active October 17, 2016 15:14
Source for trying to illustrate socket.io issue
const io = require('socket.io-client')
let socket = io.connect('http://localhost:3000')
socket.on('connect', (data) => {
let playerId
console.log('connected')
socket.on('success', () => {