Skip to content

Commit 38220fa

Browse files
fix: catch unityweb exception
1 parent 61f255f commit 38220fa

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

Runtime/BehaviourPredefined/Public/NetworkCondition.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ public struct NetworkCondition
2020
/// </summary>
2121
public long LastReceivedTick;
2222
/// <summary>
23-
/// Weighted Clock Offset in ticks.
23+
/// Weighted Local Clock Offset (LCO) in game ticks.
24+
///
25+
/// This represents the time difference between the client's local clock and the server's clock,
26+
/// smoothed using a running median filter and converted to game ticks.
2427
/// </summary>
2528
public double LcoTicks;
2629
public bool ReconciliationPerformed;
2730
public double RttTicks;
2831
public bool WasTickJumpForced;
2932
public long PredictionLimit;
30-
public double DefaultTickRate;
33+
public int DefaultTickRate;
3134
/// <summary>
3235
/// How many ticks the client had to catch up when a tick jump was forced.
3336
/// </summary>

Runtime/Communication/HttpSignalingClient.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,27 @@ public async UniTask<WebSignalingClientResponse> PostOfferAsync(string offer, Ti
2727
request.downloadHandler = new DownloadHandlerBuffer();
2828
request.SetTestCertificateHandlerIfNeeded();
2929

30-
var (isCanceled, result) = await request.SendWebRequest().ToUniTask(null, PlayerLoopTiming.Update, ct).SuppressCancellationThrow();
31-
32-
if (isCanceled)
30+
try
31+
{
32+
var (isCanceled, result) = await request.SendWebRequest().ToUniTask(null, PlayerLoopTiming.Update, ct).SuppressCancellationThrow();
33+
if (isCanceled)
34+
return new WebSignalingClientResponse
35+
{
36+
IsError = true,
37+
Text = "Operation cancelled.",
38+
Code = 499
39+
};
40+
return HandleCompleted(result);
41+
}
42+
catch (Exception e)
43+
{
3344
return new WebSignalingClientResponse
3445
{
3546
IsError = true,
36-
Text = "Operation cancelled.",
37-
Code = 499
47+
Text = e.Message,
48+
Code = 500
3849
};
39-
40-
return HandleCompleted(result);
50+
}
4151
}
4252

4353
public UniTask<WebSignalingClientResponse> OnIceCandidateCreated(string iceCandidate, TimeSpan timeout, string peerId, CancellationToken ct = default) =>

Runtime/Mappers/ClientTickCalculatorNetworkDetailsToNetworkDetailsMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static NetworkCondition MapToNetworkNetworkCondition(this ClientTickCalcu
1717
RttTicks = source.RttTicks,
1818
WasTickJumpForced = source.WasTickJumpForced,
1919
PredictionLimit = source.PredictionLimit,
20-
DefaultTickRate = source.DefaultTickRate,
20+
DefaultTickRate = (int)source.DefaultTickRate,
2121
TicksToCatchup = source.TicksToCatchup,
2222
NewTickFromCalculations = source.NewTickFromCalculations
2323
};

0 commit comments

Comments
 (0)