From e72efd9f518e7e01ce8b9fd0495ba64d837638cb Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Mon, 29 Aug 2022 09:54:29 +0000 Subject: [PATCH] game_url is added --- src/app/modules/game/main/main.component.ts | 14 ++++++-- .../polyglot/api/services/game.service.ts | 33 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/app/modules/game/main/main.component.ts b/src/app/modules/game/main/main.component.ts index 427cd4c..2e77347 100644 --- a/src/app/modules/game/main/main.component.ts +++ b/src/app/modules/game/main/main.component.ts @@ -19,8 +19,18 @@ export class GameMainComponent implements OnInit { ngOnInit(): void { this.__activatedRoute.queryParams.subscribe((params) => { console.log(params); // { orderby: "price" } - const vendor_key = params['vendor_key']; - const game_key = params['game_key']; + const vendorKey = params['vendor_key']; + const gameKey = params['game_key']; + + let r = this.__gameService + .getGameUrl(vendorKey, gameKey) + .then((r) => { + console.log('success', r.getUrl()); + window.location.href = r.getUrl(); + }) + .catch((e) => { + console.log('fail', e); + }); }); } /** diff --git a/src/app/modules/polyglot/api/services/game.service.ts b/src/app/modules/polyglot/api/services/game.service.ts index ac0a263..0640064 100644 --- a/src/app/modules/polyglot/api/services/game.service.ts +++ b/src/app/modules/polyglot/api/services/game.service.ts @@ -4,10 +4,15 @@ import { NatsService } from 'app/core/nats/services/nats.service'; import { Error } from 'app/modules/proto/protobuf/rpc_pb'; import { + GetGameUrlRequest, + GetGameUrlResponse, ListGamesRequest, ListGamesResponse, } from 'app/modules/proto/c2se/api/game_pb'; -import { SUBJECT_LIST_GAMES } from 'app/modules/proto/c2se/frontend/api/game_pb'; +import { + SUBJECT_GET_GAME_URL, + SUBJECT_LIST_GAMES, +} from 'app/modules/proto/c2se/frontend/api/game_pb'; @Injectable({ providedIn: 'root', @@ -49,4 +54,30 @@ export class GameService { }); }); } + + getGameUrl( + vendorKey: string, + gameKey: string + ): Promise { + return new Promise((resolve, reject) => { + let req = new GetGameUrlRequest(); + req.setVendorKey(vendorKey); + req.setGameKey(gameKey); + + this.__natsService + .request( + SUBJECT_GET_GAME_URL, + req.serializeBinary(), + GetGameUrlResponse.deserializeBinary + ) + .then((result) => { + console.log('success', result); + return resolve(result); + }) + .catch((e: Error) => { + console.log('failed', e); + reject(e); + }); + }); + } }