From 97d229366206fd15f8518e4d4724e779d45ba24f Mon Sep 17 00:00:00 2001 From: Richard Fox Date: Tue, 6 Mar 2018 01:48:54 +0100 Subject: [PATCH] chore(changelog): prepare 2.7.1 --- CHANGELOG.md | 4 ++++ examples/ready.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 examples/ready.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a32166..0983e6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 2.x +### 2.7.1 +- Fix a small typo in one of the examples (#93) +- Fix websocket authentication when used in browsers (#95) + ### 2.7 - Add world update methods (#94) - Adjust prettier config to Mixer standard and did a pass diff --git a/examples/ready.ts b/examples/ready.ts new file mode 100644 index 0000000..bec43c0 --- /dev/null +++ b/examples/ready.ts @@ -0,0 +1,40 @@ +/* tslint:disable:no-console */ +import * as WebSocket from 'ws'; + +import { + GameClient, + IButton, + IParticipant, + setWebSocket, +} from '../lib'; + +import { makeControls } from './util'; + +if (process.argv.length < 4) { + console.log('Usage gameClient.exe '); + process.exit(); +} +// We need to tell the interactive client what type of websocket we are using. +setWebSocket(WebSocket); + +// As we're on the Streamer's side we need a "GameClient" instance +const client = new GameClient(); + +// Log when we're connected to interactive +client.on('open', () => console.log('Connected to interactive')); + +// These can be un-commented to see the raw JSON messages under the hood +client.on('message', (err: any) => console.log('<<<', err)); +client.on('send', (err: any) => console.log('>>>', err)); +// client.on('error', (err: any) => console.log(err)); + +// Now we open the connection passing in our authentication details and an experienceId. +client.open({ + authToken: process.argv[2], + versionId: parseInt(process.argv[3], 10), +}).then(() => { + // Controls don't appear unless we tell Interactive that we are ready! + return client.ready(true); +}); + +/* tslint:enable:no-console */