-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added dynamic configuration of http port in the unity sdk #1121
Added dynamic configuration of http port in the unity sdk #1121
Conversation
b67ec4a
to
d8eefaf
Compare
Build Succeeded 👏 Build Id: 97744ec9-8924-4d7a-87ec-9a7be37dfc2d The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: 774a885e-c59a-43a0-8349-b5fc402cb63e The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
sdks/unity/AgonesSdk.cs
Outdated
@@ -153,7 +184,7 @@ private async Task<bool> SendRequestAsync(string api, string json, string method | |||
// To prevent that an async method leaks after destroying this gameObject. | |||
cancellationTokenSource.Token.ThrowIfCancellationRequested(); | |||
|
|||
var req = new UnityWebRequest(sidecarAddress + api, method) | |||
var req = new UnityWebRequest(sidecarHost + ":" + sidecarPort + api, method) | |||
{ |
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.
This is more readable: String.Format("{0}:{1}{2}", sidecarHost, sidecarPort, api);
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.
I've changed this back to how it looked originally.
d8eefaf
to
ecb609e
Compare
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.
Yes this is fine. In fact when this file was added I asked if that port was constant or if it should be a variable, and was assured it was a constant heh.
It was ... until we found a bug and decided it needed to be changed. Since we can't ensure that whatever port we pick will always be free of conflicts, we decided to make it configurable. |
sdks/unity/AgonesSdk.cs
Outdated
@@ -58,6 +58,8 @@ private struct KeyValueMessage | |||
// Use this for initialization. | |||
private void Start() | |||
{ | |||
String port = Environment.GetEnvironmentVariable("AGONES_SDK_HTTP_PORT"); | |||
sidecarAddress = "http://localhost:" + (port != null ? port : "59358"); |
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.
you can replace it with ??
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator
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.
Sweet. I've updated it.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dzlier-gcp, pooneh-m, roberthbailey The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
ecb609e
to
a343963
Compare
New changes are detected. LGTM label has been removed. |
a343963
to
98d2ffa
Compare
Build Succeeded 👏 Build Id: a591ca96-320c-448a-a441-fecee380eae7 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: 44c11c59-0413-4c37-a544-48954ba47d46 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: e0bee085-f4e0-4e44-aad9-4c8b469569c5 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
@dzlier-gcp -- I'm looking for feedback on the way that I'm getting the environment variable and converting it to an integer. This follows the pattern I implemented for Go / nodejs, but in the C++ sdk I went with a more concise solution (with less logging / error checking) since that was considered more stylistically correct.
Part of #851.