-
Notifications
You must be signed in to change notification settings - Fork 38
Addded sharecode (X-Interactive-Sharecode) #86
Conversation
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. |
src/GameClient.ts
Outdated
@@ -45,7 +52,11 @@ export class GameClient extends Client { | |||
return super.open({ | |||
authToken: options.authToken, | |||
url: endpoints[0].address, | |||
extraHeaders: { | |||
extraHeaders: | |||
(options.sharecode !== undefined) ? { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Johnny!
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.