Skip to content
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

Set timeout duration as optional argument #4050

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sdks/unity/AgonesSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ private void OnApplicationQuit()
/// Async method that waits to connect to the SDK Server. Will timeout
/// and return false after 30 seconds.
/// </summary>
/// <param name="timeoutSeconds">The number of seconds to wait before timing out. Defaults to 30 seconds.</param>
/// <returns>A task that indicated whether it was successful or not</returns>
public async Task<bool> Connect()
public async Task<bool> Connect(int timeoutSeconds = 30)
{
for (var i = 0; i < 30; i++)
for (var i = 0; i < timeoutSeconds; i++)
{
Log($"Attempting to connect...{i + 1}");
try
Expand Down
4 changes: 2 additions & 2 deletions site/content/en/docs/Guides/Client SDKs/unity.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ var agones = agonesGameObject.GetComponent<Agones.AgonesSdk>();
```

To connect to the SDK server, either local or when running on Agones, run the async `Connect()` method.
This will wait for up to 30 seconds if the SDK server has not yet started and the connection cannot be made,
and will return `false` if there was an issue connecting.
By default, this will wait for up to 30 seconds if the SDK server has not yet started and the connection cannot be made. You can specify an optional timeout duration argument to the method, e.g., Connect(60) for a 60-second timeout.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should add feature expiry around the deleted lines, and publish version around the new lines.

{{% feature expiryVersion="1.46.0" %}}
{{% /feature %}}
publish='{{% feature publishVersion="1.46.0" %}}'
{{% /feature %}}

The method will return `false` if there was an issue connecting.

```csharp
bool ok = await agones.Connect();
Expand Down
Loading