app.hypergames.hypersdk 1.11.2 → 1.11.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.11.3-beta.1](https://github.com/mvmhyper/hyper-sdk/compare/v1.11.2...v1.11.3-beta.1) (2026-10-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **sdk:** preserve socket state and reconnect on retry ([#165](https://github.com/mvmhyper/hyper-sdk/issues/165)) ([20d03a3](https://github.com/mvmhyper/hyper-sdk/commit/20d03a3f97bf340bcb04c03498d21bc3ef595185))
|
|
7
|
+
|
|
1
8
|
## [1.11.2](https://github.com/mvmhyper/hyper-sdk/compare/v1.11.1...v1.11.2) (2026-10-14)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -589,25 +589,23 @@ namespace Hyper.Internal.Managers
|
|
|
589
589
|
|
|
590
590
|
private IEnumerator StartWebSocketInitialization()
|
|
591
591
|
{
|
|
592
|
-
|
|
593
|
-
|
|
592
|
+
// Assign the coroutine handle before JS can synchronously call back.
|
|
593
|
+
yield return null;
|
|
594
|
+
InitWebSocket(GetServerUrl());
|
|
594
595
|
|
|
595
|
-
|
|
596
|
+
float elapsed = 0f;
|
|
597
|
+
const float connectionTimeout = 20f;
|
|
598
|
+
while (!isSocketConnected && elapsed < connectionTimeout)
|
|
596
599
|
{
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
yield return new WaitForSecondsRealtime(attempts == 1 ? 2f : 0.5f);
|
|
601
|
-
|
|
602
|
-
if (!isSocketConnected)
|
|
603
|
-
{
|
|
604
|
-
HyperDebug.LogWarning($"WebSocket connection attempt {attempts} failed");
|
|
605
|
-
}
|
|
600
|
+
yield return null;
|
|
601
|
+
elapsed += Time.unscaledDeltaTime;
|
|
606
602
|
}
|
|
607
603
|
|
|
604
|
+
_initWebSocketCoroutine = null;
|
|
605
|
+
|
|
608
606
|
if (!isSocketConnected)
|
|
609
607
|
{
|
|
610
|
-
HyperDebug.LogError("
|
|
608
|
+
HyperDebug.LogError("WebSocket connection timed out");
|
|
611
609
|
}
|
|
612
610
|
}
|
|
613
611
|
|
|
@@ -880,6 +878,12 @@ namespace Hyper.Internal.Managers
|
|
|
880
878
|
}
|
|
881
879
|
}
|
|
882
880
|
|
|
881
|
+
public void OnSocketSendError(string error)
|
|
882
|
+
{
|
|
883
|
+
// Serialization/emit failures do not imply a disconnected transport.
|
|
884
|
+
HyperDebug.LogError($"[WebSocket] Message send failed: {error}");
|
|
885
|
+
}
|
|
886
|
+
|
|
883
887
|
public void OnSocketError()
|
|
884
888
|
{
|
|
885
889
|
if (!_isSocketErrorCalled && !_gameManager.HasGameStarted)
|
|
@@ -1094,33 +1098,28 @@ namespace Hyper.Internal.Managers
|
|
|
1094
1098
|
private IEnumerator ReconnectionCoroutine()
|
|
1095
1099
|
{
|
|
1096
1100
|
_currentRetryCount = 0;
|
|
1097
|
-
const float
|
|
1101
|
+
const float retryDuration = 5f;
|
|
1102
|
+
float startedAt = Time.realtimeSinceStartup;
|
|
1103
|
+
int displayedSeconds = Mathf.CeilToInt(retryDuration);
|
|
1098
1104
|
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
_currentRetryCount++;
|
|
1102
|
-
_gameManager?.LoadingFailedModalComponent?.UpdateAttemptCount(_currentRetryCount);
|
|
1103
|
-
|
|
1104
|
-
float elapsed = 0f;
|
|
1105
|
-
const float connectionTimeout = 1f;
|
|
1105
|
+
_gameManager?.LoadingFailedModalComponent?.ShowRetryCountdown(displayedSeconds);
|
|
1106
|
+
InitializeWebSocket();
|
|
1106
1107
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
if (
|
|
1114
|
-
{
|
|
1115
|
-
break;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
if (_currentRetryCount < MAX_RETRY_COUNT)
|
|
1108
|
+
// Assign the retry handle before completion can restart the loader.
|
|
1109
|
+
yield return null;
|
|
1110
|
+
while (!isSocketConnected && Time.realtimeSinceStartup - startedAt < retryDuration)
|
|
1111
|
+
{
|
|
1112
|
+
float remaining = retryDuration - (Time.realtimeSinceStartup - startedAt);
|
|
1113
|
+
int secondsRemaining = Mathf.CeilToInt(remaining);
|
|
1114
|
+
if (secondsRemaining != displayedSeconds)
|
|
1119
1115
|
{
|
|
1120
|
-
|
|
1116
|
+
displayedSeconds = secondsRemaining;
|
|
1117
|
+
_gameManager?.LoadingFailedModalComponent?.ShowRetryCountdown(displayedSeconds);
|
|
1121
1118
|
}
|
|
1119
|
+
yield return null;
|
|
1122
1120
|
}
|
|
1123
1121
|
|
|
1122
|
+
_reconnectionCoroutine = null;
|
|
1124
1123
|
if (isSocketConnected)
|
|
1125
1124
|
{
|
|
1126
1125
|
_gameManager?.ShowLoadingFailedModal(false);
|
|
@@ -1128,12 +1127,11 @@ namespace Hyper.Internal.Managers
|
|
|
1128
1127
|
}
|
|
1129
1128
|
else
|
|
1130
1129
|
{
|
|
1131
|
-
|
|
1132
|
-
|
|
1130
|
+
// Restore the buttons without emitting connection-lost again, which
|
|
1131
|
+
// would stop the loader's still-pending socket initialization.
|
|
1132
|
+
_gameManager?.LoadingFailedModalComponent?.ShowRetryCountdown(0);
|
|
1133
1133
|
_gameManager?.LoadingFailedModalComponent?.AllAttemptsHaveFailed();
|
|
1134
1134
|
}
|
|
1135
|
-
|
|
1136
|
-
_reconnectionCoroutine = null;
|
|
1137
1135
|
}
|
|
1138
1136
|
|
|
1139
1137
|
#endregion
|
|
@@ -80,7 +80,7 @@ namespace Hyper.Internal
|
|
|
80
80
|
|
|
81
81
|
ConfigureReplayState();
|
|
82
82
|
|
|
83
|
-
connectionStatusIcon?.onClick.AddListener(ShowConnectionLostStatus);
|
|
83
|
+
// connectionStatusIcon?.onClick.AddListener(ShowConnectionLostStatus);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
private void ConfigureControlBarBackground()
|
|
@@ -97,7 +97,7 @@ namespace Hyper.Internal
|
|
|
97
97
|
|
|
98
98
|
private void OnDestroy()
|
|
99
99
|
{
|
|
100
|
-
connectionStatusIcon?.onClick.RemoveListener(ShowConnectionLostStatus);
|
|
100
|
+
// connectionStatusIcon?.onClick.RemoveListener(ShowConnectionLostStatus);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
private void CacheTextComponents()
|
|
@@ -10,7 +10,11 @@ mergeInto(LibraryManager.library, {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
if (window.socketInstance) {
|
|
13
|
-
|
|
13
|
+
// Preserve pending handshakes and Socket.IO's automatic reconnection.
|
|
14
|
+
if (!window.socketInstance.connected && !window.socketInstance.active) {
|
|
15
|
+
window.socketInstance.connect();
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
const socket = io(serverUrl, {
|
|
@@ -89,7 +93,7 @@ mergeInto(LibraryManager.library, {
|
|
|
89
93
|
});
|
|
90
94
|
} catch (error) {
|
|
91
95
|
console.error("[WebSocket] Error:", error);
|
|
92
|
-
SendMessage('HyperSDKSingleton', '
|
|
96
|
+
SendMessage('HyperSDKSingleton', 'OnSocketSendError', error.toString());
|
|
93
97
|
} finally {
|
|
94
98
|
payload = null;
|
|
95
99
|
messageStr = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "app.hypergames.hypersdk",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.3-beta.1",
|
|
4
4
|
"displayName": "HyperSDK",
|
|
5
5
|
"description": "Official Unity SDK for Hyper: multiplayer battles, leaderboards, deterministic RNG, session management, tutorials, and WebGL optimizations for production-ready games.",
|
|
6
6
|
"unity": "6000.0",
|