This repository was archived by the owner on Jul 31, 2020. It is now read-only.
Addded sharecode (X-Interactive-Sharecode)#86
Merged
ProbablePrime merged 3 commits intomixer:masterfrom Aug 9, 2017
JohnyCilohokla:fixes
Merged
Addded sharecode (X-Interactive-Sharecode)#86ProbablePrime merged 3 commits intomixer:masterfrom JohnyCilohokla:fixes
ProbablePrime merged 3 commits intomixer:masterfrom
JohnyCilohokla:fixes
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. |
ProbablePrime
suggested changes
Aug 3, 2017
src/GameClient.ts
Outdated
| url: endpoints[0].address, | ||
| extraHeaders: { | ||
| extraHeaders: | ||
| (options.sharecode !== undefined) ? { |
Contributor
There was a problem hiding this comment.
just
'X-Interactive-Sharecode': options.sharecode
Should be ok afaik
Contributor
Author
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
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;
}
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.