Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Addded sharecode (X-Interactive-Sharecode) #86

Merged
merged 3 commits into from
Aug 9, 2017
Merged

Addded sharecode (X-Interactive-Sharecode) #86

merged 3 commits into from
Aug 9, 2017

Conversation

JohnyCilohokla
Copy link
Contributor

Note: Checking to make sure options.sharecode is there is required, if 'X-Interactive-Version' in extraHeaders is sent in as undefined it will throw an error.

@msftclas
Copy link

msftclas commented Aug 3, 2017

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@@ -45,7 +52,11 @@ export class GameClient extends Client {
return super.open({
authToken: options.authToken,
url: endpoints[0].address,
extraHeaders: {
extraHeaders:
(options.sharecode !== undefined) ? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just

'X-Interactive-Sharecode': options.sharecode

Should be ok afaik

Copy link
Contributor Author

@JohnyCilohokla JohnyCilohokla Aug 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing just:

                extraHeaders: {
                    'X-Interactive-Version': options.versionId,
                    'X-Interactive-Sharecode': options.sharecode,
                },

results in

Exception has occurred: Error
Error: "value" required in setHeader("X-Interactive-Sharecode", value)
    at validateHeader (_http_outgoing.js:502:11)
    at ClientRequest.setHeader (_http_outgoing.js:511:3)
    at new ClientRequest (_http_client.js:171:14)
    at Object.request (http.js:39:10)
    at Object.request (https.js:233:15)
    at Object.get (https.js:237:21)
    at WebSocket.initAsClient (...\node_modules\ws\lib\WebSocket.js:635:23)
...

if 'X-Interactive-Version' is set as undefined

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, ok i understand.

The issue here is i don't like the repetition of extraHeaders.

how about we construct an object and then add attributes to it.

const extraHeaders = {
'X-Interactive-Version': options.versionId,
};
if(options.sharecode) {
extraHeaders['X-Interactive-Sharecode'] = options.sharecode;
}

@JohnyCilohokla

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I get that, changed @ProbablePrime

Copy link
Contributor

@ProbablePrime ProbablePrime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Johnny!

@ProbablePrime ProbablePrime merged commit b0c5b9f into mixer:master Aug 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

3 participants