Skip to content

Commit

Permalink
Revert changes in socketio.js and api.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonharrison committed Sep 30, 2019
1 parent ddc635b commit 7d7271f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/client/transport/socketio.js
Expand Up @@ -40,7 +40,6 @@ export class SocketIO {
this.store = store;
this.socketOpts = socketOpts;
this.gameName = gameName || 'default';
this.gameName = this.gameName.replace(' ', '-');
this.gameID = gameID || 'default';
this.playerID = playerID || null;
this.numPlayers = numPlayers || 2;
Expand Down
14 changes: 7 additions & 7 deletions src/server/api.ts
Expand Up @@ -82,7 +82,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {

router.post('/games/:name/create', koaBody(), async ctx => {
// The name of the game (for example: tic-tac-toe).
const gameName = ctx.params.name.replace(' ', '-');
const gameName = ctx.params.name;
// User-data to pass to the game setup function.
const setupData = ctx.request.body.setupData;
// The number of players for this game instance.
Expand All @@ -106,7 +106,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.get('/games/:name', async ctx => {
const gameName = ctx.params.name.replace(' ', '-');
const gameName = ctx.params.name;
const gameList = await db.list();
let rooms = [];
for (let key of [...gameList]) {
Expand All @@ -131,7 +131,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.get('/games/:name/:id', async ctx => {
const gameName = ctx.params.name.replace(' ', '-');
const gameName = ctx.params.name;
const gameID = ctx.params.id;
const room = await db.get(`${gameName}:${GameMetadataKey(gameID)}`);
if (!room) {
Expand All @@ -155,7 +155,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
if (!playerName) {
ctx.throw(403, 'playerName is required');
}
const gameName = ctx.params.name.replace(' ', '-');
const gameName = ctx.params.name;
const roomID = ctx.params.id;
const namespacedGameID = getNamespacedGameID(roomID, gameName);
const gameMetadata = await db.get(GameMetadataKey(namespacedGameID));
Expand All @@ -180,7 +180,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.post('/games/:name/:id/leave', koaBody(), async ctx => {
const gameName = ctx.params.name.replace(' ', '-');
const gameName = ctx.params.name;
const roomID = ctx.params.id;
const playerID = ctx.request.body.playerID;
const credentials = ctx.request.body.credentials;
Expand Down Expand Up @@ -212,7 +212,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.post('/games/:name/:id/playAgain', koaBody(), async ctx => {
const gameName = ctx.params.name.replace(' ', '-');
const gameName = ctx.params.name;
const roomID = ctx.params.id;
const playerID = ctx.request.body.playerID;
const credentials = ctx.request.body.credentials;
Expand Down Expand Up @@ -264,7 +264,7 @@ export const addApiToServer = ({ app, db, games, lobbyConfig }) => {
});

router.post('/games/:name/:id/rename', koaBody(), async ctx => {
const gameName = ctx.params.name.replace(' ', '-');
const gameName = ctx.params.name;
const roomID = ctx.params.id;
const playerID = ctx.request.body.playerID;
const credentials = ctx.request.body.credentials;
Expand Down

0 comments on commit 7d7271f

Please sign in to comment.