From 9de5220ed6b48d29571d4c54a6a73a3d170706d9 Mon Sep 17 00:00:00 2001 From: ProbablePrime Date: Fri, 9 Jun 2017 12:53:56 +0200 Subject: [PATCH 1/3] Customizable discovery url --- src/EndpointDiscovery.ts | 4 +--- src/GameClient.ts | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EndpointDiscovery.ts b/src/EndpointDiscovery.ts index 00f8792..32658a4 100644 --- a/src/EndpointDiscovery.ts +++ b/src/EndpointDiscovery.ts @@ -5,8 +5,6 @@ export interface IInteractiveEndpoint { address: string; } -const endpoint = `https://beam.pro/api/v1/interactive/hosts`; - export class EndpointDiscovery { constructor(private requester: IRequester) {} /** @@ -15,7 +13,7 @@ export class EndpointDiscovery { * other servers in the list should a connection attempt to the first * fail. */ - public retrieveEndpoints(): Promise { + public retrieveEndpoints(endpoint: string = 'https://beam.pro/api/v1/interactive/hosts'): Promise { return this.requester.request(endpoint) .then(res => { if (res.length > 0) { diff --git a/src/GameClient.ts b/src/GameClient.ts index 5d4ed4c..2c01bcb 100644 --- a/src/GameClient.ts +++ b/src/GameClient.ts @@ -21,10 +21,12 @@ export interface IGameClientOptions { * An OAuth Bearer token as defined in {@link https://art.tools.ietf.org/html/rfc6750| OAuth 2.0 Bearer Token Usage}. */ authToken: string; + /** - * An interactive server url, these should be retrieved from https://beam.pro/api/v1/interactive/hosts. + * A url which can be used to discover interactive servers. + * Defaults to https://mixer.com/api/v1/interactive/hosts */ - url?: string; + discoveryUrl?: string; } export class GameClient extends Client { @@ -37,7 +39,7 @@ export class GameClient extends Client { */ public open(options: IGameClientOptions): Promise { return this.discovery - .retrieveEndpoints() + .retrieveEndpoints(options.discoveryUrl) .then(endpoints => { return super.open({ authToken: options.authToken, From 6ed357c2c43c4be5b237c07e7a0a0d7650b11ae2 Mon Sep 17 00:00:00 2001 From: ProbablePrime Date: Fri, 9 Jun 2017 13:45:14 +0200 Subject: [PATCH 2/3] fix build --- examples/dynamicControls.ts | 2 +- examples/updateControl.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/dynamicControls.ts b/examples/dynamicControls.ts index 55acea7..445003b 100644 --- a/examples/dynamicControls.ts +++ b/examples/dynamicControls.ts @@ -12,7 +12,7 @@ import { setWebSocket, } from '../lib'; -if (process.argv.length < 5) { +if (process.argv.length < 4) { console.log('Usage gameClient.exe '); process.exit(); } diff --git a/examples/updateControl.ts b/examples/updateControl.ts index 08d762b..51fa09d 100644 --- a/examples/updateControl.ts +++ b/examples/updateControl.ts @@ -9,7 +9,7 @@ import { setWebSocket, } from '../lib'; -if (process.argv.length < 5) { +if (process.argv.length < 4) { console.log('Usage gameClient.exe '); process.exit(); } @@ -71,7 +71,6 @@ function makeControls(amount: number): IControlData[] { // Now we open the connection passing in our authentication details and an experienceId. client.open({ authToken: process.argv[2], - url: process.argv[3], versionId: parseInt(process.argv[4], 10), }) .then(() => { From ad9053918f2d08dbce6a86a607e6020aa1fb4f51 Mon Sep 17 00:00:00 2001 From: ProbablePrime Date: Fri, 9 Jun 2017 13:47:45 +0200 Subject: [PATCH 3/3] Beam -> Mixer --- examples/groups.ts | 2 +- src/EndpointDiscovery.ts | 4 ++-- src/GameClient.ts | 2 +- src/ParticipantClient.ts | 6 +++--- src/state/State.ts | 8 ++++---- src/state/interfaces/IParticipant.ts | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/groups.ts b/examples/groups.ts index c01193c..21241ab 100644 --- a/examples/groups.ts +++ b/examples/groups.ts @@ -160,7 +160,7 @@ function createGroups(): Promise { // Now we open the connection passing in our authentication details and an experienceId. client - // Open the Beam client with command line args + // Open the Mixer interactive client with command line args .open({ authToken: process.argv[2], versionId: parseInt(process.argv[3], 10), diff --git a/src/EndpointDiscovery.ts b/src/EndpointDiscovery.ts index 32658a4..3d854b4 100644 --- a/src/EndpointDiscovery.ts +++ b/src/EndpointDiscovery.ts @@ -8,12 +8,12 @@ export interface IInteractiveEndpoint { export class EndpointDiscovery { constructor(private requester: IRequester) {} /** - * Retrieves available interactive servers from Beam's REST API. + * Retrieves available interactive servers from Mixer's REST API. * Game Clients should connect to the first one in the list and use * other servers in the list should a connection attempt to the first * fail. */ - public retrieveEndpoints(endpoint: string = 'https://beam.pro/api/v1/interactive/hosts'): Promise { + public retrieveEndpoints(endpoint: string = 'https://mixer.com/api/v1/interactive/hosts'): Promise { return this.requester.request(endpoint) .then(res => { if (res.length > 0) { diff --git a/src/GameClient.ts b/src/GameClient.ts index 2c01bcb..98412b3 100644 --- a/src/GameClient.ts +++ b/src/GameClient.ts @@ -14,7 +14,7 @@ import { IControl } from './state/interfaces/controls/IControl'; export interface IGameClientOptions { /** * Your project version id is a unique id to your Interactive Project Version. You can retrieve one - * from the Interactive Studio on Beam.pro in the Code step. + * from the Interactive Studio on Mixer.com in the Code step. */ versionId: number; /** diff --git a/src/ParticipantClient.ts b/src/ParticipantClient.ts index 16b8d64..de6718f 100644 --- a/src/ParticipantClient.ts +++ b/src/ParticipantClient.ts @@ -4,13 +4,13 @@ import { IInput } from './state/interfaces/controls'; export interface IParticipantOptions { /** - * A JWT representing a Beam.pro session + * A JWT representing a Mixer.com session */ jwt: string; /** * A url for the Interactive session you'd like to join. - * This should be retrieved from https://beam.pro/api/v1/interactive/{channelId} - * @example wss://interactive1-dal.beam.pro/participant?channel= + * This should be retrieved from https://mixer.com/api/v1/interactive/{channelId} + * @example wss://interactive1-dal.mixer.com/participant?channel= */ url: string; /** diff --git a/src/state/State.ts b/src/state/State.ts index fe197b7..0a568ca 100644 --- a/src/state/State.ts +++ b/src/state/State.ts @@ -49,7 +49,7 @@ export class State extends EventEmitter implements IState { /** * Constructs a new State instance. Based on the passed client type it will - * hook into the apropriate methods for that type to keep itself up to date. + * hook into the appropriate methods for that type to keep itself up to date. */ constructor(private clientType: ClientType) { super(); @@ -187,7 +187,7 @@ export class State extends EventEmitter implements IState { } /** - * Returns the local time matched to the sync of the Beam server clock. + * Returns the local time matched to the sync of the Mixer server clock. */ public synchronizeLocalTime(time: Date | number = Date.now()): Date { if (time instanceof Date) { @@ -346,14 +346,14 @@ export class State extends EventEmitter implements IState { return result; } /** - * Retrieve a participant by their Beam UserId. + * Retrieve a participant by their Mixer UserId. */ public getParticipantByUserID(id: number): IParticipant { return this.getParticipantBy('userID', id); } /** - * Retrieve a participant by their Beam Username. + * Retrieve a participant by their Mixer Username. */ public getParticipantByUsername(name: string): IParticipant { return this.getParticipantBy('username', name); diff --git a/src/state/interfaces/IParticipant.ts b/src/state/interfaces/IParticipant.ts index e440176..3602316 100644 --- a/src/state/interfaces/IParticipant.ts +++ b/src/state/interfaces/IParticipant.ts @@ -13,15 +13,15 @@ export interface IParticipant { */ sessionID: string; /** - * This participant's Beam UserId + * This participant's Mixer UserId */ userID?: number; /** - * This participant's Beam Username + * This participant's Mixer Username */ username?: string; /** - * This participant's Beam level + * This participant's Mixer level */ level?: number; /**