This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| host: "qlikathon.qlik.com", | |
| socketPort: 3000, | |
| apiPort: 8080, | |
| apiId: "<id>", | |
| apiSecret: "<secret>" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log("Welcome to the Qritter Wars Client") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', () => { |
NewerOlder