Skip to content
This repository was archived by the owner on Jul 31, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/dynamicControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
setWebSocket,
} from '../lib';

if (process.argv.length < 5) {
if (process.argv.length < 4) {
console.log('Usage gameClient.exe <token> <versionId>');
process.exit();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function createGroups(): Promise<void> {

// 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),
Expand Down
3 changes: 1 addition & 2 deletions examples/updateControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
setWebSocket,
} from '../lib';

if (process.argv.length < 5) {
if (process.argv.length < 4) {
console.log('Usage gameClient.exe <token> <url> <experienceId>');
process.exit();
}
Expand Down Expand Up @@ -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(() => {
Expand Down
6 changes: 2 additions & 4 deletions src/EndpointDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ export interface IInteractiveEndpoint {
address: string;
}

const endpoint = `https://beam.pro/api/v1/interactive/hosts`;

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(): Promise<IInteractiveEndpoint[]> {
public retrieveEndpoints(endpoint: string = 'https://mixer.com/api/v1/interactive/hosts'): Promise<IInteractiveEndpoint[]> {
return this.requester.request(endpoint)
.then(res => {
if (res.length > 0) {
Expand Down
10 changes: 6 additions & 4 deletions src/GameClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ 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;
/**
* 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 {
Expand All @@ -37,7 +39,7 @@ export class GameClient extends Client {
*/
public open(options: IGameClientOptions): Promise<this> {
return this.discovery
.retrieveEndpoints()
.retrieveEndpoints(options.discoveryUrl)
.then(endpoints => {
return super.open({
authToken: options.authToken,
Expand Down
6 changes: 3 additions & 3 deletions src/ParticipantClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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=<channelid>
* This should be retrieved from https://mixer.com/api/v1/interactive/{channelId}
* @example wss://interactive1-dal.mixer.com/participant?channel=<channelid>
*/
url: string;
/**
Expand Down
8 changes: 4 additions & 4 deletions src/state/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/state/interfaces/IParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down