-
Notifications
You must be signed in to change notification settings - Fork 77
Conversation
@@ -87,6 +87,7 @@ public async Task Connect(string workerType, ILogDispatcher logger) | |||
var origin = transform.position; | |||
ConnectionDelegate connectionDelegate; | |||
var chosenService = GetConnectionService(); | |||
Debug.Log(chosenService); |
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.
Remove debug print
|
||
if (!string.IsNullOrEmpty(pit.Error)) | ||
{ | ||
throw new ConnectionFailedException(pit.Error, ConnectionErrorReason.InvalidConfig); |
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.
Is InvalidConfig
actually a valid reason for failure in every case, here and below?
What if it's a different reason, for example if the service is down?
ConnectionErrorReason.InvalidConfig); | ||
} | ||
|
||
if (!loginTokenRequestResult.Value.Status.Equals(ConnectionStatusCode.Success)) |
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.
Why ! .Equals
, rather than !=
?
f91e915
to
c468489
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.
Looks good overall!
@@ -1,8 +1,8 @@ | |||
{ | |||
"name": "unity_gdk", | |||
"project_version": "0.0.1", | |||
"sdk_version": "13.5.0-b7795-fdd6a-WORKER-SNAPSHOT", | |||
"sdk_version": "13.5.0", |
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.
🎉
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.
Does this not break our tracking?
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.
as discussed internally: as long as we are not doing a new release it should be ok
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.
Yup - ticket to track: https://improbableio.atlassian.net/browse/UTY-1580
@@ -55,6 +59,26 @@ protected override string GetHostIp() | |||
#endif | |||
} | |||
|
|||
protected override string GetPlayerId() |
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.
Do we want to move this to MobileWorkerConnector to avoid duplication?
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.
There's definitely some code duplication here (and in the Android one) that could be factored down to the parent class
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.
yeah, agreed. on one hand, I want the user to define it, on the other hand, this is only needed in very specific cases, so the user shouldn't need to always define it... I might just move the default all the way up to the WorkerConnector until we can finally refactor this.
{ | ||
var loginTokenRequestResult = DevelopmentAuthentication.CreateDevelopmentLoginTokensAsync( | ||
RuntimeConfigDefaults.LocatorHost, | ||
444, |
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.
DevelopmentPlayerIdentityTokenPort?
|
||
public async void TryConnect() | ||
public async void TryConnect(ConnectionService connectionService) |
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 think @samiwh noted on this in another PR - but should async methods have async in the name. I.e. - TryConnectAsync
@@ -55,6 +59,26 @@ protected override string GetHostIp() | |||
#endif | |||
} | |||
|
|||
protected override string GetPlayerId() |
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.
There's definitely some code duplication here (and in the Android one) that could be factored down to the parent class
protected virtual string SelectLoginToken(List<LoginTokenDetails> loginTokens) | ||
{ | ||
return null; | ||
} |
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.
Need docstrings on the new protected virtual
methods in the class
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.
ah, knew I had forgotten something
protected virtual string GetDisplayName() | ||
{ | ||
return null; | ||
} |
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 know this similar to other functions defined here - but I feel we should either provide a reasonable default implementation or make these fully abstract
.
Returning null as a default implementation seems likely to break things later on.
workers/unity/Packages/com.improbable.gdk.core/Worker/WorkerConnector.cs
Outdated
Show resolved
Hide resolved
|
||
if (loginTokenRequestResult.Value.Status != ConnectionStatusCode.Success) | ||
{ | ||
throw new ConnectionFailedException($"Failed to retrieve login token, " + |
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'd rather have a slightly longer line length than the string concatenation here.
Mild preference though
@@ -27,7 +27,7 @@ public static class LaunchArguments | |||
} | |||
catch (Exception e) | |||
{ | |||
UnityEngine.Debug.LogException(e); | |||
UnityEngine.Debug.LogWarning($"Failed to retrieve launch arguments: {e}"); |
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.
Exception -> Warning? What's the context here?
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 will always fail, if you run this in the editor after switching to Android as current platform
therefore, it is expected behaviour to fail depending on what exactly you do and it shouldn't throw an exception imo
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.
Should this function even be able to be called in the editor then if it will always fail?
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.
fair point. we could also change the part where it's called to only get called if android and not editor. or wrap this part here around an #if UNITY_EDITOR
, which I would slightly prefer as it makes it safe to call for users that are not familiar with the code.
Also changelog 😛 |
workers/unity/Packages/com.improbable.gdk.core/Exceptions/AuthenticationFailedException.cs
Outdated
Show resolved
Hide resolved
workers/unity/Packages/com.improbable.gdk.core/Worker/Worker.cs
Outdated
Show resolved
Hide resolved
@@ -27,17 +28,20 @@ public void Awake() | |||
if (!string.IsNullOrEmpty(hostIp)) | |||
{ | |||
ipAddressInput.text = hostIp; | |||
TryConnect(); |
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.
Is this intentional change? If I understand correctly this was here to automatically connect to host locally when we launch with command line arguments
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 intentional, should have probably commented that earlier. Now that we can either connect to a local or a cloud deployment, we don‘t want to try and immediately connect to a local deployment all the time. Sure, we could remove the ip in the config, but I think this is a nicer solution as the other one would mean that you would have to look up for local ip again
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.
Fine with me if this is explicit change.
I'd point out that this was only triggered from launch menu, where I'd expect people mostly launch for local, but I understand the reasoning.
I think this is another pointer that we need to rethink how we implement client launch configuration so that it is more transparent and processing logic is easier to separate out.
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'm not too sure about this. As it is not required to upload the android clients to the cloud deployment, I could imagine that people want to quickly iterate and test changes and try them out in a running cloud deployment. I simply don't think we should try to immediately connect, if there are now two ways to connect, but this is all code in the playground so developers will likely use a different interface to decide how to connect.
Not sure I understand what you mean by the second point. Do you mean how we decide whether to connect to a local or a cloud deployment?
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.
Agree, this approach is more flexible.
For my second point I have a general feeling that we can improve the launch configuration and processing both in tooling and in Playground as a sample, but I don't have concrete suggestions as of the moment. Will try to think more about this and maybe come up with something more concrete.
@@ -8,6 +8,7 @@ public static class LaunchArguments | |||
{ | |||
public static Dictionary<string, string> GetArguments() | |||
{ | |||
#if !UNITY_EDITOR |
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.
Was this malfunctioning in Unity Editor?
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, as jamie and I were discussing in one of the previous threads in this PR: you can set your current platform to Android in the Editor, which will cause this code to be run. However using these java objects will only succeed in an actual android device/emulator. You end up with a nullpointer exception.
So either
- we don‘t throw an exception
- we don‘t run this code in the editor
We decided that not running it seems like the better option, because this code shouldn‘t fail on an actual android device
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.
Would it be better to wrap this in Application.isEditor
rather than compiling it out?
namespace Improbable.Gdk.Core | ||
{ | ||
/// <summary> | ||
/// Represents an error that occurs when the local state of a SpatialOS entity is not valid. |
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 doc doesn't seem to reflect the exception name
@@ -8,6 +8,7 @@ public static class LaunchArguments | |||
{ | |||
public static Dictionary<string, string> GetArguments() | |||
{ | |||
#if !UNITY_EDITOR |
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.
Would it be better to wrap this in Application.isEditor
rather than compiling it out?
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.
Mostly LGTM - one small thing I'm not sure about.
throw new AuthenticationFailedException("Did not receive a player identity token."); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(result.Value.Error)) |
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 think you should only check for null
as the underlying C API returns a null pointer if there is no error. Not sure how this gets transformed into the C# struct. cc @davedissian
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.
Checked with David, we can actually just use the status code
} | ||
|
||
/// <summary> | ||
/// Retrieves the login tokens of all active deployments that the player |
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.
Nit: Retrieves the login tokens for all active deployments...
Description
Tests
Tested on both iOS and Android. Works as expected
Documentation
docs will follow in a separate PR
Primary reviewers
If your change will take a long time to review, you can name at most two primary reviewers who are ultimately responsible for reviewing this request. @ mention them.