This repository has been archived by the owner on Jul 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
277b22d
commit 97d2293
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <token> <versionId>'); | ||
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 */ |