summaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2018-04-28 15:51:36 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2018-04-28 15:55:49 +0200
commit34050b1278bbe4d1ebd3cf8af4bf7a2b11a813b2 (patch)
tree61b98ab4a9119456d128d41fa5232e34f5e84634 /frontend/src
parentMigrate to Spring Boot Starter Security (diff)
downloadseven-wonders-34050b1278bbe4d1ebd3cf8af4bf7a2b11a813b2.tar.gz
seven-wonders-34050b1278bbe4d1ebd3cf8af4bf7a2b11a813b2.tar.bz2
seven-wonders-34050b1278bbe4d1ebd3cf8af4bf7a2b11a813b2.zip
Fix and order seven wonders JS client
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/api/sevenWondersApi.js37
1 files changed, 25 insertions, 12 deletions
diff --git a/frontend/src/api/sevenWondersApi.js b/frontend/src/api/sevenWondersApi.js
index 534045c8..b5a7df7e 100644
--- a/frontend/src/api/sevenWondersApi.js
+++ b/frontend/src/api/sevenWondersApi.js
@@ -6,12 +6,13 @@ import type {
ApiPlayerMove,
ApiPlayerTurnInfo,
ApiPreparedCard,
+ ApiSettings,
ApiTable,
} from './model';
import type { JsonStompClient, SubscribeFn } from './websocket';
import { createJsonStompClient } from './websocket';
-const wsURL = '/seven-wonders-websocket';
+const WS_URL = '/seven-wonders-websocket';
export class SevenWondersSession {
client: JsonStompClient;
@@ -24,14 +25,14 @@ export class SevenWondersSession {
return this.client.subscriber('/user/queue/errors');
}
- chooseName(displayName: string): void {
- this.client.send('/app/chooseName', { playerName: displayName });
- }
-
watchNameChoice(): SubscribeFn<ApiPlayer> {
return this.client.subscriber('/user/queue/nameChoice');
}
+ chooseName(displayName: string): void {
+ this.client.send('/app/chooseName', { playerName: displayName });
+ }
+
watchGames(): SubscribeFn<ApiLobby[]> {
return this.client.subscriber('/topic/games');
}
@@ -40,6 +41,14 @@ export class SevenWondersSession {
return this.client.subscriber('/user/queue/lobby/joined');
}
+ createGame(gameName: string): void {
+ this.client.send('/app/lobby/create', { gameName });
+ }
+
+ joinGame(gameId: number): void {
+ this.client.send('/app/lobby/join', { gameId });
+ }
+
watchLobbyUpdated(currentGameId: number): SubscribeFn<Object> {
return this.client.subscriber(`/topic/lobby/${currentGameId}/updated`);
}
@@ -48,12 +57,16 @@ export class SevenWondersSession {
return this.client.subscriber(`/topic/lobby/${currentGameId}/started`);
}
- createGame(gameName: string): void {
- this.client.send('/app/lobby/create', { gameName });
+ leave(): void {
+ this.client.send('/app/lobby/leave');
}
- joinGame(gameId: number): void {
- this.client.send('/app/lobby/join', { gameId });
+ reorderPlayers(orderedPlayers: Array<string>): void {
+ this.client.send('/app/lobby/reorderPlayers', { orderedPlayers });
+ }
+
+ updateSettings(settings: ApiSettings): void {
+ this.client.send('/app/lobby/updateSettings', { settings });
}
startGame(): void {
@@ -73,7 +86,7 @@ export class SevenWondersSession {
}
watchTurnInfo(): SubscribeFn<ApiPlayerTurnInfo> {
- return this.client.subscriber('/user/queue/game/turnInfo');
+ return this.client.subscriber('/user/queue/game/turn');
}
sayReady(): void {
@@ -81,12 +94,12 @@ export class SevenWondersSession {
}
prepareMove(move: ApiPlayerMove): void {
- this.client.send('/app/game/sayReady', { move });
+ this.client.send('/app/game/prepareMove', { move });
}
}
export async function connectToGame(): Promise<SevenWondersSession> {
- const jsonStompClient: JsonStompClient = createJsonStompClient(wsURL);
+ const jsonStompClient: JsonStompClient = createJsonStompClient(WS_URL);
await jsonStompClient.connect();
return new SevenWondersSession(jsonStompClient);
}
bgstack15