From a788e4ff8111b4fd27b5d4dc4c21cbbd245ec6a4 Mon Sep 17 00:00:00 2001 From: Johny Date: Thu, 3 Aug 2017 00:38:53 +0100 Subject: [PATCH 1/3] Addded sharecode (X-Interactive-Sharecode) --- src/GameClient.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/GameClient.ts b/src/GameClient.ts index b9b3297..c92ae6d 100644 --- a/src/GameClient.ts +++ b/src/GameClient.ts @@ -18,6 +18,13 @@ export interface IGameClientOptions { * from the Interactive Studio on Mixer.com in the Code step. */ versionId: number; + + /** + * Optional project sharecode to your Interactive Project Version. You can retrieve one + * from the Interactive Studio on Mixer.com in the Code step. + */ + sharecode?: string; + /** * An OAuth Bearer token as defined in {@link https://art.tools.ietf.org/html/rfc6750| OAuth 2.0 Bearer Token Usage}. */ @@ -45,9 +52,13 @@ export class GameClient extends Client { return super.open({ authToken: options.authToken, url: endpoints[0].address, - extraHeaders: { - 'X-Interactive-Version': options.versionId, - }, + extraHeaders: + (options.sharecode!==undefined) ? { + 'X-Interactive-Version': options.versionId, + 'X-Interactive-Sharecode': options.sharecode, + } : { + 'X-Interactive-Version': options.versionId, + }, }); }); } From adad6e830a728baf099ebe16f5ee21c893a5f8d2 Mon Sep 17 00:00:00 2001 From: Johny Date: Thu, 3 Aug 2017 01:41:16 +0100 Subject: [PATCH 2/3] tslint --- src/GameClient.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/GameClient.ts b/src/GameClient.ts index c92ae6d..dd58c85 100644 --- a/src/GameClient.ts +++ b/src/GameClient.ts @@ -24,7 +24,7 @@ export interface IGameClientOptions { * from the Interactive Studio on Mixer.com in the Code step. */ sharecode?: string; - + /** * An OAuth Bearer token as defined in {@link https://art.tools.ietf.org/html/rfc6750| OAuth 2.0 Bearer Token Usage}. */ @@ -52,13 +52,13 @@ export class GameClient extends Client { return super.open({ authToken: options.authToken, url: endpoints[0].address, - extraHeaders: - (options.sharecode!==undefined) ? { - 'X-Interactive-Version': options.versionId, - 'X-Interactive-Sharecode': options.sharecode, - } : { - 'X-Interactive-Version': options.versionId, - }, + extraHeaders: + (options.sharecode !== undefined) ? { + 'X-Interactive-Version': options.versionId, + 'X-Interactive-Sharecode': options.sharecode, + } : { + 'X-Interactive-Version': options.versionId, + }, }); }); } From 69636f0041e67b46f03aa4bb5e48db314053c06a Mon Sep 17 00:00:00 2001 From: Johny Date: Tue, 8 Aug 2017 02:57:48 +0100 Subject: [PATCH 3/3] Moved extraHeaders to a separate object --- src/GameClient.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/GameClient.ts b/src/GameClient.ts index dd58c85..f7bf3bc 100644 --- a/src/GameClient.ts +++ b/src/GameClient.ts @@ -46,19 +46,20 @@ export class GameClient extends Client { * Opens a connection to the interactive service using the provided options. */ public open(options: IGameClientOptions): Promise { + const extraHeaders = { + 'X-Interactive-Version': options.versionId, + }; + if (options.sharecode) { + extraHeaders['X-Interactive-Sharecode'] = options.sharecode; + } + return this.discovery .retrieveEndpoints(options.discoveryUrl) .then(endpoints => { return super.open({ authToken: options.authToken, url: endpoints[0].address, - extraHeaders: - (options.sharecode !== undefined) ? { - 'X-Interactive-Version': options.versionId, - 'X-Interactive-Sharecode': options.sharecode, - } : { - 'X-Interactive-Version': options.versionId, - }, + extraHeaders: extraHeaders, }); }); }