@gbraver-burst-network/anonymous-browser-sdk 2.3.0 → 2.5.0-beta.0
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/lib/abort-controller/abort-error.d.ts +7 -0
- package/lib/abort-controller/abort-error.js +11 -0
- package/lib/abort-controller/abort-manager.d.ts +17 -0
- package/lib/abort-controller/abort-manager.js +58 -0
- package/lib/abort-controller/signal-container.d.ts +5 -0
- package/lib/abort-controller/signal-container.js +2 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +2 -2
- package/lib/sdk/{guest-anonymous-sdk.d.ts → guest/guest-anonymous-sdk.d.ts} +1 -1
- package/lib/sdk/{guest-anonymous-sdk.js → guest/guest-anonymous-sdk.js} +39 -23
- package/lib/sdk/{guest-battle-sdk.d.ts → guest/guest-battle-sdk.d.ts} +4 -1
- package/lib/sdk/{guest-battle-sdk.js → guest/guest-battle-sdk.js} +17 -6
- package/lib/sdk/{guest-webrtc-connection-manager.d.ts → guest/guest-webrtc-connection-manager.d.ts} +1 -1
- package/lib/sdk/{guest-webrtc-connection-manager.js → guest/guest-webrtc-connection-manager.js} +2 -2
- package/lib/sdk/{host-anonymous-sdk.js → host/host-anonymous-sdk.js} +17 -6
- package/lib/sdk/{host-battle-sdk.d.ts → host/host-battle-sdk.d.ts} +4 -1
- package/lib/sdk/{host-battle-sdk.js → host/host-battle-sdk.js} +20 -7
- package/lib/sdk/{host-webrtc-connection-manager.d.ts → host/host-webrtc-connection-manager.d.ts} +1 -1
- package/lib/sdk/{host-webrtc-connection-manager.js → host/host-webrtc-connection-manager.js} +1 -1
- package/lib/sdk/{local-webrtc-room.d.ts → host/local-webrtc-room.d.ts} +6 -3
- package/lib/sdk/{local-webrtc-room.js → host/local-webrtc-room.js} +36 -21
- package/lib/webrtc/gather-all-ice-candidate.d.ts +4 -1
- package/lib/webrtc/gather-all-ice-candidate.js +17 -2
- package/lib/webrtc/guest/guest-message.d.ts +9 -1
- package/lib/webrtc/guest/guest-message.js +5 -1
- package/lib/webrtc/guest/guest-ping-pong-check.d.ts +12 -0
- package/lib/webrtc/guest/guest-ping-pong-check.js +47 -0
- package/lib/webrtc/guest/receive-battle-progressed.d.ts +7 -2
- package/lib/webrtc/guest/receive-battle-progressed.js +18 -3
- package/lib/webrtc/guest/receive-battle-start.d.ts +7 -2
- package/lib/webrtc/guest/receive-battle-start.js +18 -3
- package/lib/webrtc/guest/receive-request-selected-player.d.ts +7 -2
- package/lib/webrtc/guest/receive-request-selected-player.js +18 -3
- package/lib/webrtc/guest/wait-until-data-channel.d.ts +4 -1
- package/lib/webrtc/guest/wait-until-data-channel.js +23 -5
- package/lib/webrtc/host/host-message.d.ts +9 -1
- package/lib/webrtc/host/host-message.js +5 -1
- package/lib/webrtc/host/host-ping-pong-check.d.ts +12 -0
- package/lib/webrtc/host/host-ping-pong-check.js +47 -0
- package/lib/webrtc/host/receive-send-command.d.ts +10 -4
- package/lib/webrtc/host/receive-send-command.js +20 -5
- package/lib/webrtc/host/request-selected-player.d.ts +9 -3
- package/lib/webrtc/host/request-selected-player.js +19 -4
- package/lib/webrtc/wait-until-connected.d.ts +4 -1
- package/lib/webrtc/wait-until-connected.js +17 -2
- package/lib/webrtc/wait-until-data-channel-ready.d.ts +4 -1
- package/lib/webrtc/wait-until-data-channel-ready.js +17 -2
- package/lib/websocket-api/connect-ws-signal.d.ts +3 -1
- package/lib/websocket-api/connect-ws-signal.js +15 -1
- package/lib/websocket-api/create-room.d.ts +7 -1
- package/lib/websocket-api/create-room.js +18 -2
- package/lib/websocket-api/delete-signaling-channel.d.ts +3 -1
- package/lib/websocket-api/delete-signaling-channel.js +15 -2
- package/lib/websocket-api/join-room.d.ts +3 -1
- package/lib/websocket-api/join-room.js +15 -2
- package/lib/websocket-api/wait-until-matching.d.ts +7 -2
- package/lib/websocket-api/wait-until-matching.js +18 -3
- package/lib/websocket-api/wait-until-sdp-recieve.d.ts +7 -2
- package/lib/websocket-api/wait-until-sdp-recieve.js +18 -2
- package/package.json +7 -7
- /package/lib/sdk/{host-anonymous-sdk.d.ts → host/host-anonymous-sdk.d.ts} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAbortError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* AbortErrorを生成する
|
|
6
|
+
* 本関数で生成する例外はfetchのAbortSignalがabortされた際に発生するものを模倣している
|
|
7
|
+
* @param message エラーメッセージ
|
|
8
|
+
* @returns AbortError
|
|
9
|
+
*/
|
|
10
|
+
const createAbortError = (message) => new DOMException(message, "AbortError");
|
|
11
|
+
exports.createAbortError = createAbortError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abort管理オブジェクト
|
|
3
|
+
* Abortされた場合にあたらしいAbortControllerを生成する
|
|
4
|
+
* 本クラスはゲーム内で一つのみ生成される想定である
|
|
5
|
+
*/
|
|
6
|
+
export declare class AbortManager {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* コンストラクタ
|
|
10
|
+
*/
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* 現在有効なAbortControllerを取得する
|
|
14
|
+
* @returns 取得結果
|
|
15
|
+
*/
|
|
16
|
+
getAbortController(): AbortController;
|
|
17
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _AbortManager_instances, _AbortManager_abortController, _AbortManager_onAbortBound, _AbortManager_onAbort;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AbortManager = void 0;
|
|
16
|
+
/**
|
|
17
|
+
* Abort管理オブジェクト
|
|
18
|
+
* Abortされた場合にあたらしいAbortControllerを生成する
|
|
19
|
+
* 本クラスはゲーム内で一つのみ生成される想定である
|
|
20
|
+
*/
|
|
21
|
+
class AbortManager {
|
|
22
|
+
/**
|
|
23
|
+
* コンストラクタ
|
|
24
|
+
*/
|
|
25
|
+
constructor() {
|
|
26
|
+
_AbortManager_instances.add(this);
|
|
27
|
+
/** 現在有効なAbortController */
|
|
28
|
+
_AbortManager_abortController.set(this, void 0);
|
|
29
|
+
/**
|
|
30
|
+
* プライベート関数#onAbortをthisでbindした関数
|
|
31
|
+
* bind(this)は新しい関数を生成するため、以下コードではコールバック関数の削除が正しく行えない
|
|
32
|
+
* そのため、本プロパティにbindした関数を保持し、コールバック関数の削除を行えるようにする。
|
|
33
|
+
*
|
|
34
|
+
* ```typescript
|
|
35
|
+
* abortController.signal.addEventListener("abort", this.#onAbort.bind(this));
|
|
36
|
+
* abortController.signal.removeEventListener("abort", this.#onAbort.bind(this));
|
|
37
|
+
* ```
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
_AbortManager_onAbortBound.set(this, void 0);
|
|
41
|
+
__classPrivateFieldSet(this, _AbortManager_abortController, new AbortController(), "f");
|
|
42
|
+
__classPrivateFieldSet(this, _AbortManager_onAbortBound, __classPrivateFieldGet(this, _AbortManager_instances, "m", _AbortManager_onAbort).bind(this), "f");
|
|
43
|
+
__classPrivateFieldGet(this, _AbortManager_abortController, "f").signal.addEventListener("abort", __classPrivateFieldGet(this, _AbortManager_onAbortBound, "f"));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 現在有効なAbortControllerを取得する
|
|
47
|
+
* @returns 取得結果
|
|
48
|
+
*/
|
|
49
|
+
getAbortController() {
|
|
50
|
+
return __classPrivateFieldGet(this, _AbortManager_abortController, "f");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.AbortManager = AbortManager;
|
|
54
|
+
_AbortManager_abortController = new WeakMap(), _AbortManager_onAbortBound = new WeakMap(), _AbortManager_instances = new WeakSet(), _AbortManager_onAbort = function _AbortManager_onAbort() {
|
|
55
|
+
__classPrivateFieldGet(this, _AbortManager_abortController, "f").signal.removeEventListener("abort", __classPrivateFieldGet(this, _AbortManager_onAbortBound, "f"));
|
|
56
|
+
__classPrivateFieldSet(this, _AbortManager_abortController, new AbortController(), "f");
|
|
57
|
+
__classPrivateFieldGet(this, _AbortManager_abortController, "f").signal.addEventListener("abort", __classPrivateFieldGet(this, _AbortManager_onAbortBound, "f"));
|
|
58
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AnonymousBattleSDK } from "./sdk/anonymous-battle-sdk";
|
|
2
2
|
export { AuthTokenManager, createAuthTokenManager, } from "./sdk/auth-token-manager";
|
|
3
|
-
export { createGuestAnonymousSDK, GuestAnonymousSDK, } from "./sdk/guest-anonymous-sdk";
|
|
4
|
-
export { createHostAnonymousSDK, HostAnonymousSDK, } from "./sdk/host-anonymous-sdk";
|
|
5
|
-
export { LocalWebRTCRoom } from "./sdk/local-webrtc-room";
|
|
3
|
+
export { createGuestAnonymousSDK, GuestAnonymousSDK, } from "./sdk/guest/guest-anonymous-sdk";
|
|
4
|
+
export { createHostAnonymousSDK, HostAnonymousSDK, } from "./sdk/host/host-anonymous-sdk";
|
|
5
|
+
export { LocalWebRTCRoom } from "./sdk/host/local-webrtc-room";
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createHostAnonymousSDK = exports.createGuestAnonymousSDK = exports.createAuthTokenManager = void 0;
|
|
4
4
|
var auth_token_manager_1 = require("./sdk/auth-token-manager");
|
|
5
5
|
Object.defineProperty(exports, "createAuthTokenManager", { enumerable: true, get: function () { return auth_token_manager_1.createAuthTokenManager; } });
|
|
6
|
-
var guest_anonymous_sdk_1 = require("./sdk/guest-anonymous-sdk");
|
|
6
|
+
var guest_anonymous_sdk_1 = require("./sdk/guest/guest-anonymous-sdk");
|
|
7
7
|
Object.defineProperty(exports, "createGuestAnonymousSDK", { enumerable: true, get: function () { return guest_anonymous_sdk_1.createGuestAnonymousSDK; } });
|
|
8
|
-
var host_anonymous_sdk_1 = require("./sdk/host-anonymous-sdk");
|
|
8
|
+
var host_anonymous_sdk_1 = require("./sdk/host/host-anonymous-sdk");
|
|
9
9
|
Object.defineProperty(exports, "createHostAnonymousSDK", { enumerable: true, get: function () { return host_anonymous_sdk_1.createHostAnonymousSDK; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArmdozerId, PilotId } from "gbraver-burst-core";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
|
-
import { AnonymousBattleSDK } from "
|
|
3
|
+
import { AnonymousBattleSDK } from "../anonymous-battle-sdk";
|
|
4
4
|
import { GuestWebRTCConnectionManagerOptions } from "./guest-webrtc-connection-manager";
|
|
5
5
|
/** ゲスト用匿名バックエンドSDK */
|
|
6
6
|
export type GuestAnonymousSDK = {
|
|
@@ -19,25 +19,27 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
19
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
21
|
};
|
|
22
|
-
var _GuestAnonymousSDKImpl_instances, _GuestAnonymousSDKImpl_webRTCConnection, _GuestAnonymousSDKImpl_websocketConnection, _GuestAnonymousSDKImpl_frontendLog, _GuestAnonymousSDKImpl_signaling;
|
|
22
|
+
var _GuestAnonymousSDKImpl_instances, _GuestAnonymousSDKImpl_webRTCConnection, _GuestAnonymousSDKImpl_websocketConnection, _GuestAnonymousSDKImpl_frontendLog, _GuestAnonymousSDKImpl_abortManager, _GuestAnonymousSDKImpl_signaling;
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.createGuestAnonymousSDK = createGuestAnonymousSDK;
|
|
25
25
|
const nanoid_1 = require("nanoid");
|
|
26
26
|
const rxjs_1 = require("rxjs");
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
27
|
+
const abort_manager_1 = require("../../abort-controller/abort-manager");
|
|
28
|
+
const gather_all_ice_candidate_1 = require("../../webrtc/gather-all-ice-candidate");
|
|
29
|
+
const get_selected_ice_candidate_summary_1 = require("../../webrtc/get-selected-ice-candidate-summary");
|
|
30
|
+
const guest_message_1 = require("../../webrtc/guest/guest-message");
|
|
31
|
+
const guest_ping_pong_check_1 = require("../../webrtc/guest/guest-ping-pong-check");
|
|
32
|
+
const receive_battle_start_1 = require("../../webrtc/guest/receive-battle-start");
|
|
33
|
+
const receive_request_selected_player_1 = require("../../webrtc/guest/receive-request-selected-player");
|
|
34
|
+
const wait_until_connected_1 = require("../../webrtc/wait-until-connected");
|
|
35
|
+
const join_room_1 = require("../../websocket-api/join-room");
|
|
36
|
+
const notify_ice_candidate_recieved_1 = require("../../websocket-api/notify-ice-candidate-recieved");
|
|
37
|
+
const send_to_ws_signal_1 = require("../../websocket-api/send-to-ws-signal");
|
|
38
|
+
const wait_until_sdp_recieve_1 = require("../../websocket-api/wait-until-sdp-recieve");
|
|
39
|
+
const frontend_log_manager_1 = require("../frontend-log-manager");
|
|
40
|
+
const websocket_connection_manager_1 = require("../websocket-connection-manager");
|
|
38
41
|
const guest_battle_sdk_1 = require("./guest-battle-sdk");
|
|
39
42
|
const guest_webrtc_connection_manager_1 = require("./guest-webrtc-connection-manager");
|
|
40
|
-
const websocket_connection_manager_1 = require("./websocket-connection-manager");
|
|
41
43
|
/** ゲスト用匿名バックエンドSDKの実装 */
|
|
42
44
|
class GuestAnonymousSDKImpl {
|
|
43
45
|
/**
|
|
@@ -52,13 +54,20 @@ class GuestAnonymousSDKImpl {
|
|
|
52
54
|
_GuestAnonymousSDKImpl_websocketConnection.set(this, void 0);
|
|
53
55
|
/** フロントエンドログマネージャー */
|
|
54
56
|
_GuestAnonymousSDKImpl_frontendLog.set(this, void 0);
|
|
57
|
+
/** アボート管理オブジェクト */
|
|
58
|
+
_GuestAnonymousSDKImpl_abortManager.set(this, void 0);
|
|
55
59
|
__classPrivateFieldSet(this, _GuestAnonymousSDKImpl_webRTCConnection, new guest_webrtc_connection_manager_1.GuestWebRTCConnectionManager(options), "f");
|
|
56
60
|
__classPrivateFieldSet(this, _GuestAnonymousSDKImpl_websocketConnection, new websocket_connection_manager_1.WebSocketConnectionManager(options), "f");
|
|
57
61
|
__classPrivateFieldSet(this, _GuestAnonymousSDKImpl_frontendLog, new frontend_log_manager_1.FrontendLogManager(options), "f");
|
|
62
|
+
__classPrivateFieldSet(this, _GuestAnonymousSDKImpl_abortManager, new abort_manager_1.AbortManager(), "f");
|
|
58
63
|
}
|
|
59
64
|
/** @override */
|
|
60
65
|
joinRoom(options) {
|
|
61
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const { signal } = __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_abortManager, "f").getAbortController();
|
|
68
|
+
if (signal.aborted) {
|
|
69
|
+
return Promise.reject(signal.reason);
|
|
70
|
+
}
|
|
62
71
|
const spanId = (0, nanoid_1.nanoid)();
|
|
63
72
|
const { roomID, armdozerId, pilotId } = options;
|
|
64
73
|
__classPrivateFieldGet(this, _GuestAnonymousSDKImpl_websocketConnection, "f").gracefulDisconnect();
|
|
@@ -66,21 +75,23 @@ class GuestAnonymousSDKImpl {
|
|
|
66
75
|
// イベントを取り逃がさないように、あらかじめハンドラをセットしておく
|
|
67
76
|
const requestSelectedPlayerPromise = (() => __awaiter(this, void 0, void 0, function* () {
|
|
68
77
|
const dataChannel = yield __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_webRTCConnection, "f").getOrCreateConnection().dataChannelPromise;
|
|
69
|
-
return yield (0, receive_request_selected_player_1.receiveRequestSelectedPlayer)(dataChannel);
|
|
78
|
+
return yield (0, receive_request_selected_player_1.receiveRequestSelectedPlayer)({ dataChannel, signal });
|
|
70
79
|
}))();
|
|
71
80
|
const battleStartPromise = (() => __awaiter(this, void 0, void 0, function* () {
|
|
72
81
|
const dataChannel = yield __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_webRTCConnection, "f").getOrCreateConnection().dataChannelPromise;
|
|
73
|
-
return yield (0, receive_battle_start_1.receiveBattleStart)(dataChannel);
|
|
82
|
+
return yield (0, receive_battle_start_1.receiveBattleStart)({ dataChannel, signal });
|
|
74
83
|
}))();
|
|
75
84
|
const websocket = yield __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_websocketConnection, "f").getOrCreate();
|
|
76
|
-
const joinRoomAccepted = yield (0, join_room_1.joinRoom)({ websocket, roomID });
|
|
85
|
+
const joinRoomAccepted = yield (0, join_room_1.joinRoom)({ websocket, roomID, signal });
|
|
77
86
|
if (!joinRoomAccepted) {
|
|
78
87
|
return null;
|
|
79
88
|
}
|
|
80
89
|
const { signalingID } = joinRoomAccepted;
|
|
81
|
-
yield __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_instances, "m", _GuestAnonymousSDKImpl_signaling).call(this, { signalingID, spanId });
|
|
82
|
-
const { flowID } = yield requestSelectedPlayerPromise;
|
|
90
|
+
yield __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_instances, "m", _GuestAnonymousSDKImpl_signaling).call(this, { signalingID, spanId, signal });
|
|
83
91
|
const dataChannel = yield __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_webRTCConnection, "f").getOrCreateConnection().dataChannelPromise;
|
|
92
|
+
yield (0, guest_ping_pong_check_1.guestPingPongCheck)({ dataChannel, signal });
|
|
93
|
+
const { flowID } = yield requestSelectedPlayerPromise;
|
|
94
|
+
__classPrivateFieldGet(this, _GuestAnonymousSDKImpl_websocketConnection, "f").gracefulDisconnect();
|
|
84
95
|
(0, guest_message_1.sendGuestMessage)(dataChannel, {
|
|
85
96
|
type: "send-player",
|
|
86
97
|
flowID,
|
|
@@ -94,6 +105,7 @@ class GuestAnonymousSDKImpl {
|
|
|
94
105
|
initialState: battleStart.update,
|
|
95
106
|
initialFlowID: battleStart.flowID,
|
|
96
107
|
webRTCConnection: __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_webRTCConnection, "f"),
|
|
108
|
+
abortManager: __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_abortManager, "f"),
|
|
97
109
|
});
|
|
98
110
|
});
|
|
99
111
|
}
|
|
@@ -104,15 +116,20 @@ class GuestAnonymousSDKImpl {
|
|
|
104
116
|
/** @override */
|
|
105
117
|
disconnectWebSocket() {
|
|
106
118
|
__classPrivateFieldGet(this, _GuestAnonymousSDKImpl_websocketConnection, "f").gracefulDisconnect();
|
|
119
|
+
__classPrivateFieldGet(this, _GuestAnonymousSDKImpl_abortManager, "f").getAbortController().abort("WebSocket disconnected");
|
|
107
120
|
}
|
|
108
121
|
/** @override */
|
|
109
122
|
disconnectWebRTC() {
|
|
110
123
|
__classPrivateFieldGet(this, _GuestAnonymousSDKImpl_webRTCConnection, "f").disconnect();
|
|
124
|
+
__classPrivateFieldGet(this, _GuestAnonymousSDKImpl_abortManager, "f").getAbortController().abort("WebRTC disconnected");
|
|
111
125
|
}
|
|
112
126
|
}
|
|
113
|
-
_GuestAnonymousSDKImpl_webRTCConnection = new WeakMap(), _GuestAnonymousSDKImpl_websocketConnection = new WeakMap(), _GuestAnonymousSDKImpl_frontendLog = new WeakMap(), _GuestAnonymousSDKImpl_instances = new WeakSet(), _GuestAnonymousSDKImpl_signaling = function _GuestAnonymousSDKImpl_signaling(options) {
|
|
127
|
+
_GuestAnonymousSDKImpl_webRTCConnection = new WeakMap(), _GuestAnonymousSDKImpl_websocketConnection = new WeakMap(), _GuestAnonymousSDKImpl_frontendLog = new WeakMap(), _GuestAnonymousSDKImpl_abortManager = new WeakMap(), _GuestAnonymousSDKImpl_instances = new WeakSet(), _GuestAnonymousSDKImpl_signaling = function _GuestAnonymousSDKImpl_signaling(options) {
|
|
114
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
const { signalingID, spanId } = options;
|
|
129
|
+
const { signalingID, spanId, signal } = options;
|
|
130
|
+
if (signal.aborted) {
|
|
131
|
+
return Promise.reject(signal.reason);
|
|
132
|
+
}
|
|
116
133
|
let unSubscribers = [];
|
|
117
134
|
try {
|
|
118
135
|
yield __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_frontendLog, "f").log({
|
|
@@ -151,7 +168,7 @@ _GuestAnonymousSDKImpl_webRTCConnection = new WeakMap(), _GuestAnonymousSDKImpl_
|
|
|
151
168
|
});
|
|
152
169
|
}),
|
|
153
170
|
];
|
|
154
|
-
const remoteSDP = yield (0, wait_until_sdp_recieve_1.waitUntilSDPReceive)(websocket);
|
|
171
|
+
const remoteSDP = yield (0, wait_until_sdp_recieve_1.waitUntilSDPReceive)({ websocket, signal });
|
|
155
172
|
yield connection.setRemoteDescription(remoteSDP);
|
|
156
173
|
isRemoteDescriptionSet = true;
|
|
157
174
|
pendingIceCandidates.forEach((iceCandidate) => {
|
|
@@ -164,7 +181,7 @@ _GuestAnonymousSDKImpl_webRTCConnection = new WeakMap(), _GuestAnonymousSDKImpl_
|
|
|
164
181
|
signalingID,
|
|
165
182
|
sdp,
|
|
166
183
|
});
|
|
167
|
-
yield (0, wait_until_connected_1.waitUntilConnected)(connection);
|
|
184
|
+
yield (0, wait_until_connected_1.waitUntilConnected)(connection, { signal });
|
|
168
185
|
yield __classPrivateFieldGet(this, _GuestAnonymousSDKImpl_frontendLog, "f").log({
|
|
169
186
|
type: "SIGNALING_END",
|
|
170
187
|
spanId,
|
|
@@ -179,7 +196,6 @@ _GuestAnonymousSDKImpl_webRTCConnection = new WeakMap(), _GuestAnonymousSDKImpl_
|
|
|
179
196
|
}
|
|
180
197
|
}
|
|
181
198
|
finally {
|
|
182
|
-
__classPrivateFieldGet(this, _GuestAnonymousSDKImpl_websocketConnection, "f").gracefulDisconnect();
|
|
183
199
|
unSubscribers.forEach((unSubscriber) => unSubscriber.unsubscribe());
|
|
184
200
|
}
|
|
185
201
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command, GameState, Player } from "gbraver-burst-core";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
|
-
import {
|
|
3
|
+
import { AbortManager } from "../../abort-controller/abort-manager";
|
|
4
|
+
import { AnonymousBattleSDK } from "../anonymous-battle-sdk";
|
|
4
5
|
import { GuestWebRTCConnectionManager } from "./guest-webrtc-connection-manager";
|
|
5
6
|
/** ゲスト側バトルSDK */
|
|
6
7
|
export declare class GuestBattleSDK implements AnonymousBattleSDK {
|
|
@@ -21,6 +22,7 @@ export declare class GuestBattleSDK implements AnonymousBattleSDK {
|
|
|
21
22
|
* @param options.initialState ゲームの初期状態
|
|
22
23
|
* @param options.initialFlowID 初期のフローID
|
|
23
24
|
* @param options.webRTCConnection ホストのWebRTCコネクションマネージャー
|
|
25
|
+
* @param options.abortManager アボート管理オブジェクト
|
|
24
26
|
*/
|
|
25
27
|
constructor(options: {
|
|
26
28
|
hostPlayer: Player;
|
|
@@ -28,6 +30,7 @@ export declare class GuestBattleSDK implements AnonymousBattleSDK {
|
|
|
28
30
|
initialState: GameState[];
|
|
29
31
|
initialFlowID: string;
|
|
30
32
|
webRTCConnection: GuestWebRTCConnectionManager;
|
|
33
|
+
abortManager: AbortManager;
|
|
31
34
|
});
|
|
32
35
|
/** @override */
|
|
33
36
|
progress(command: Command): Promise<GameState[]>;
|
|
@@ -19,13 +19,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
19
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
21
|
};
|
|
22
|
-
var _GuestBattleSDK_webRTCConnection, _GuestBattleSDK_sendExceptionSubject;
|
|
22
|
+
var _GuestBattleSDK_webRTCConnection, _GuestBattleSDK_sendExceptionSubject, _GuestBattleSDK_abortManager;
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.GuestBattleSDK = void 0;
|
|
25
25
|
const rxjs_1 = require("rxjs");
|
|
26
|
-
const guest_message_1 = require("
|
|
27
|
-
const receive_battle_progressed_1 = require("
|
|
28
|
-
const notify_connection_failed_1 = require("
|
|
26
|
+
const guest_message_1 = require("../../webrtc/guest/guest-message");
|
|
27
|
+
const receive_battle_progressed_1 = require("../../webrtc/guest/receive-battle-progressed");
|
|
28
|
+
const notify_connection_failed_1 = require("../../webrtc/notify-connection-failed");
|
|
29
29
|
/** ゲスト側バトルSDK */
|
|
30
30
|
class GuestBattleSDK {
|
|
31
31
|
/**
|
|
@@ -36,23 +36,34 @@ class GuestBattleSDK {
|
|
|
36
36
|
* @param options.initialState ゲームの初期状態
|
|
37
37
|
* @param options.initialFlowID 初期のフローID
|
|
38
38
|
* @param options.webRTCConnection ホストのWebRTCコネクションマネージャー
|
|
39
|
+
* @param options.abortManager アボート管理オブジェクト
|
|
39
40
|
*/
|
|
40
41
|
constructor(options) {
|
|
41
42
|
/** ホストのWebRTCコネクションマネージャー */
|
|
42
43
|
_GuestBattleSDK_webRTCConnection.set(this, void 0);
|
|
43
44
|
/** dataChannel.sendの例外通知ストリーム */
|
|
44
45
|
_GuestBattleSDK_sendExceptionSubject.set(this, new rxjs_1.Subject());
|
|
46
|
+
/** アボート管理オブジェクト */
|
|
47
|
+
_GuestBattleSDK_abortManager.set(this, void 0);
|
|
45
48
|
this.player = options.guestPlayer;
|
|
46
49
|
this.enemy = options.hostPlayer;
|
|
47
50
|
this.initialState = options.initialState;
|
|
48
51
|
this.flowID = options.initialFlowID;
|
|
49
52
|
__classPrivateFieldSet(this, _GuestBattleSDK_webRTCConnection, options.webRTCConnection, "f");
|
|
53
|
+
__classPrivateFieldSet(this, _GuestBattleSDK_abortManager, options.abortManager, "f");
|
|
50
54
|
}
|
|
51
55
|
/** @override */
|
|
52
56
|
progress(command) {
|
|
53
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const { signal } = __classPrivateFieldGet(this, _GuestBattleSDK_abortManager, "f").getAbortController();
|
|
59
|
+
if (signal.aborted) {
|
|
60
|
+
return Promise.reject(signal.reason);
|
|
61
|
+
}
|
|
54
62
|
const dataChannel = yield __classPrivateFieldGet(this, _GuestBattleSDK_webRTCConnection, "f").getOrCreateConnection().dataChannelPromise;
|
|
55
|
-
const battleProgressedPromise = (0, receive_battle_progressed_1.receiveBattleProgressed)(
|
|
63
|
+
const battleProgressedPromise = (0, receive_battle_progressed_1.receiveBattleProgressed)({
|
|
64
|
+
dataChannel,
|
|
65
|
+
signal,
|
|
66
|
+
});
|
|
56
67
|
try {
|
|
57
68
|
(0, guest_message_1.sendGuestMessage)(dataChannel, {
|
|
58
69
|
type: "send-command",
|
|
@@ -75,4 +86,4 @@ class GuestBattleSDK {
|
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
exports.GuestBattleSDK = GuestBattleSDK;
|
|
78
|
-
_GuestBattleSDK_webRTCConnection = new WeakMap(), _GuestBattleSDK_sendExceptionSubject = new WeakMap();
|
|
89
|
+
_GuestBattleSDK_webRTCConnection = new WeakMap(), _GuestBattleSDK_sendExceptionSubject = new WeakMap(), _GuestBattleSDK_abortManager = new WeakMap();
|
package/lib/sdk/{guest-webrtc-connection-manager.js → guest/guest-webrtc-connection-manager.js}
RENAMED
|
@@ -13,8 +13,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _GuestWebRTCConnectionManager_authToken, _GuestWebRTCConnectionManager_connectionState, _GuestWebRTCConnectionManager_anonymousBackendApiURL, _GuestWebRTCConnectionManager_coturnDomainName;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.GuestWebRTCConnectionManager = void 0;
|
|
16
|
-
const wait_until_data_channel_1 = require("
|
|
17
|
-
const create_rtc_peer_connection_1 = require("
|
|
16
|
+
const wait_until_data_channel_1 = require("../../webrtc/guest/wait-until-data-channel");
|
|
17
|
+
const create_rtc_peer_connection_1 = require("../create-rtc-peer-connection");
|
|
18
18
|
/** ゲストのWebRTCコネクション管理 */
|
|
19
19
|
class GuestWebRTCConnectionManager {
|
|
20
20
|
/** コンストラクタ
|
|
@@ -19,15 +19,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
19
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
21
|
};
|
|
22
|
-
var _HostAnonymousSDKImpl_webRTCConnection, _HostAnonymousSDKImpl_websocketConnection, _HostAnonymousSDKImpl_frontendLog;
|
|
22
|
+
var _HostAnonymousSDKImpl_webRTCConnection, _HostAnonymousSDKImpl_websocketConnection, _HostAnonymousSDKImpl_frontendLog, _HostAnonymousSDKImpl_abortManager;
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.createHostAnonymousSDK = createHostAnonymousSDK;
|
|
25
25
|
const nanoid_1 = require("nanoid");
|
|
26
|
-
const
|
|
27
|
-
const
|
|
26
|
+
const abort_manager_1 = require("../../abort-controller/abort-manager");
|
|
27
|
+
const create_room_1 = require("../../websocket-api/create-room");
|
|
28
|
+
const frontend_log_manager_1 = require("../frontend-log-manager");
|
|
29
|
+
const websocket_connection_manager_1 = require("../websocket-connection-manager");
|
|
28
30
|
const host_webrtc_connection_manager_1 = require("./host-webrtc-connection-manager");
|
|
29
31
|
const local_webrtc_room_1 = require("./local-webrtc-room");
|
|
30
|
-
const websocket_connection_manager_1 = require("./websocket-connection-manager");
|
|
31
32
|
/** ホスト用匿名バックエンドSDKの実装 */
|
|
32
33
|
class HostAnonymousSDKImpl {
|
|
33
34
|
/**
|
|
@@ -41,19 +42,26 @@ class HostAnonymousSDKImpl {
|
|
|
41
42
|
_HostAnonymousSDKImpl_websocketConnection.set(this, void 0);
|
|
42
43
|
/** フロントエンドログマネージャー */
|
|
43
44
|
_HostAnonymousSDKImpl_frontendLog.set(this, void 0);
|
|
45
|
+
/** アボート管理オブジェクト */
|
|
46
|
+
_HostAnonymousSDKImpl_abortManager.set(this, void 0);
|
|
44
47
|
__classPrivateFieldSet(this, _HostAnonymousSDKImpl_websocketConnection, new websocket_connection_manager_1.WebSocketConnectionManager(options), "f");
|
|
45
48
|
__classPrivateFieldSet(this, _HostAnonymousSDKImpl_webRTCConnection, new host_webrtc_connection_manager_1.HostWebRTCConnectionManager(options), "f");
|
|
46
49
|
__classPrivateFieldSet(this, _HostAnonymousSDKImpl_frontendLog, new frontend_log_manager_1.FrontendLogManager(options), "f");
|
|
50
|
+
__classPrivateFieldSet(this, _HostAnonymousSDKImpl_abortManager, new abort_manager_1.AbortManager(), "f");
|
|
47
51
|
}
|
|
48
52
|
/** @override */
|
|
49
53
|
createRoom(options) {
|
|
50
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const { signal } = __classPrivateFieldGet(this, _HostAnonymousSDKImpl_abortManager, "f").getAbortController();
|
|
56
|
+
if (signal.aborted) {
|
|
57
|
+
return Promise.reject(signal.reason);
|
|
58
|
+
}
|
|
51
59
|
const spanId = (0, nanoid_1.nanoid)();
|
|
52
60
|
try {
|
|
53
61
|
__classPrivateFieldGet(this, _HostAnonymousSDKImpl_websocketConnection, "f").gracefulDisconnect();
|
|
54
62
|
__classPrivateFieldGet(this, _HostAnonymousSDKImpl_webRTCConnection, "f").disconnect();
|
|
55
63
|
const websocket = yield __classPrivateFieldGet(this, _HostAnonymousSDKImpl_websocketConnection, "f").getOrCreate();
|
|
56
|
-
const roomID = yield (0, create_room_1.createRoom)(websocket);
|
|
64
|
+
const roomID = yield (0, create_room_1.createRoom)({ websocket, signal });
|
|
57
65
|
if (roomID === null) {
|
|
58
66
|
__classPrivateFieldGet(this, _HostAnonymousSDKImpl_websocketConnection, "f").gracefulDisconnect();
|
|
59
67
|
return null;
|
|
@@ -67,6 +75,7 @@ class HostAnonymousSDKImpl {
|
|
|
67
75
|
frontendLog: __classPrivateFieldGet(this, _HostAnonymousSDKImpl_frontendLog, "f"),
|
|
68
76
|
hostArmdozerId,
|
|
69
77
|
hostPilotId,
|
|
78
|
+
abortManager: __classPrivateFieldGet(this, _HostAnonymousSDKImpl_abortManager, "f"),
|
|
70
79
|
});
|
|
71
80
|
}
|
|
72
81
|
catch (e) {
|
|
@@ -82,13 +91,15 @@ class HostAnonymousSDKImpl {
|
|
|
82
91
|
/** @override */
|
|
83
92
|
disconnectWebSocket() {
|
|
84
93
|
__classPrivateFieldGet(this, _HostAnonymousSDKImpl_websocketConnection, "f").gracefulDisconnect();
|
|
94
|
+
__classPrivateFieldGet(this, _HostAnonymousSDKImpl_abortManager, "f").getAbortController().abort("WebSocket disconnected");
|
|
85
95
|
}
|
|
86
96
|
/** @override */
|
|
87
97
|
disconnectWebRTC() {
|
|
88
98
|
__classPrivateFieldGet(this, _HostAnonymousSDKImpl_webRTCConnection, "f").disconnect();
|
|
99
|
+
__classPrivateFieldGet(this, _HostAnonymousSDKImpl_abortManager, "f").getAbortController().abort("WebRTC disconnected");
|
|
89
100
|
}
|
|
90
101
|
}
|
|
91
|
-
_HostAnonymousSDKImpl_webRTCConnection = new WeakMap(), _HostAnonymousSDKImpl_websocketConnection = new WeakMap(), _HostAnonymousSDKImpl_frontendLog = new WeakMap();
|
|
102
|
+
_HostAnonymousSDKImpl_webRTCConnection = new WeakMap(), _HostAnonymousSDKImpl_websocketConnection = new WeakMap(), _HostAnonymousSDKImpl_frontendLog = new WeakMap(), _HostAnonymousSDKImpl_abortManager = new WeakMap();
|
|
92
103
|
/**
|
|
93
104
|
* ホスト用匿名バックエンドSDKを生成する
|
|
94
105
|
* @param options SDK生成のオプション
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArmdozerId, Command, GameState, PilotId, Player } from "gbraver-burst-core";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
|
-
import {
|
|
3
|
+
import { AbortManager } from "../../abort-controller/abort-manager";
|
|
4
|
+
import { AnonymousBattleSDK } from "../anonymous-battle-sdk";
|
|
4
5
|
import { HostWebRTCConnectionManager } from "./host-webrtc-connection-manager";
|
|
5
6
|
/** ホスト側バトルSDK */
|
|
6
7
|
export declare class HostBattleSDK implements AnonymousBattleSDK {
|
|
@@ -21,6 +22,7 @@ export declare class HostBattleSDK implements AnonymousBattleSDK {
|
|
|
21
22
|
* @param options.guestArmdozerId ゲスト側のアームドーザID
|
|
22
23
|
* @param options.guestPilotId ゲスト側のパイロットID
|
|
23
24
|
* @param options.webRTCConnection ホスト側のWebRTC接続マネージャー
|
|
25
|
+
* @param options.abortManager アボート管理オブジェクト
|
|
24
26
|
*/
|
|
25
27
|
constructor(options: {
|
|
26
28
|
hostArmdozerId: ArmdozerId;
|
|
@@ -28,6 +30,7 @@ export declare class HostBattleSDK implements AnonymousBattleSDK {
|
|
|
28
30
|
guestArmdozerId: ArmdozerId;
|
|
29
31
|
guestPilotId: PilotId;
|
|
30
32
|
webRTCConnection: HostWebRTCConnectionManager;
|
|
33
|
+
abortManager: AbortManager;
|
|
31
34
|
});
|
|
32
35
|
/** @override */
|
|
33
36
|
progress(command: Command): Promise<GameState[]>;
|
|
@@ -19,15 +19,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
19
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
21
|
};
|
|
22
|
-
var _HostBattleSDK_core, _HostBattleSDK_webRTCConnection, _HostBattleSDK_sendCommandPromise, _HostBattleSDK_sendExceptionSubject;
|
|
22
|
+
var _HostBattleSDK_core, _HostBattleSDK_webRTCConnection, _HostBattleSDK_sendCommandPromise, _HostBattleSDK_sendExceptionSubject, _HostBattleSDK_abortManager;
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.HostBattleSDK = void 0;
|
|
25
25
|
const gbraver_burst_core_1 = require("gbraver-burst-core");
|
|
26
26
|
const nanoid_1 = require("nanoid");
|
|
27
27
|
const rxjs_1 = require("rxjs");
|
|
28
|
-
const host_message_1 = require("
|
|
29
|
-
const receive_send_command_1 = require("
|
|
30
|
-
const notify_connection_failed_1 = require("
|
|
28
|
+
const host_message_1 = require("../../webrtc/host/host-message");
|
|
29
|
+
const receive_send_command_1 = require("../../webrtc/host/receive-send-command");
|
|
30
|
+
const notify_connection_failed_1 = require("../../webrtc/notify-connection-failed");
|
|
31
31
|
/** ホスト側バトルSDK */
|
|
32
32
|
class HostBattleSDK {
|
|
33
33
|
/**
|
|
@@ -38,6 +38,7 @@ class HostBattleSDK {
|
|
|
38
38
|
* @param options.guestArmdozerId ゲスト側のアームドーザID
|
|
39
39
|
* @param options.guestPilotId ゲスト側のパイロットID
|
|
40
40
|
* @param options.webRTCConnection ホスト側のWebRTC接続マネージャー
|
|
41
|
+
* @param options.abortManager アボート管理オブジェクト
|
|
41
42
|
*/
|
|
42
43
|
constructor(options) {
|
|
43
44
|
var _a, _b, _c, _d;
|
|
@@ -49,6 +50,8 @@ class HostBattleSDK {
|
|
|
49
50
|
_HostBattleSDK_sendCommandPromise.set(this, void 0);
|
|
50
51
|
/** dataChannel.sendの例外通知ストリーム */
|
|
51
52
|
_HostBattleSDK_sendExceptionSubject.set(this, new rxjs_1.Subject());
|
|
53
|
+
/** アボート管理オブジェクト */
|
|
54
|
+
_HostBattleSDK_abortManager.set(this, void 0);
|
|
52
55
|
const hostPlayerId = (0, nanoid_1.nanoid)();
|
|
53
56
|
this.player = {
|
|
54
57
|
playerId: hostPlayerId,
|
|
@@ -63,15 +66,21 @@ class HostBattleSDK {
|
|
|
63
66
|
};
|
|
64
67
|
__classPrivateFieldSet(this, _HostBattleSDK_core, (0, gbraver_burst_core_1.startGBraverBurst)([this.player, this.enemy]), "f");
|
|
65
68
|
this.initialState = __classPrivateFieldGet(this, _HostBattleSDK_core, "f").stateHistory();
|
|
69
|
+
__classPrivateFieldSet(this, _HostBattleSDK_abortManager, options.abortManager, "f");
|
|
70
|
+
const { signal } = __classPrivateFieldGet(this, _HostBattleSDK_abortManager, "f").getAbortController();
|
|
66
71
|
this.flowID = (0, nanoid_1.nanoid)();
|
|
67
72
|
__classPrivateFieldSet(this, _HostBattleSDK_webRTCConnection, options.webRTCConnection, "f");
|
|
68
73
|
__classPrivateFieldSet(this, _HostBattleSDK_sendCommandPromise, __classPrivateFieldGet(this, _HostBattleSDK_webRTCConnection, "f")
|
|
69
74
|
.getOrCreateConnection()
|
|
70
|
-
.then(({ dataChannel }) => (0, receive_send_command_1.receiveSendCommand)(dataChannel, this.flowID)), "f");
|
|
75
|
+
.then(({ dataChannel }) => (0, receive_send_command_1.receiveSendCommand)({ dataChannel, flowID: this.flowID, signal })), "f");
|
|
71
76
|
}
|
|
72
77
|
/** @override */
|
|
73
78
|
progress(command) {
|
|
74
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const { signal } = __classPrivateFieldGet(this, _HostBattleSDK_abortManager, "f").getAbortController();
|
|
81
|
+
if (signal.aborted) {
|
|
82
|
+
return Promise.reject(signal.reason);
|
|
83
|
+
}
|
|
75
84
|
const sendCommand = yield __classPrivateFieldGet(this, _HostBattleSDK_sendCommandPromise, "f");
|
|
76
85
|
const hostCommand = { playerId: this.player.playerId, command };
|
|
77
86
|
const guestCommand = {
|
|
@@ -81,7 +90,11 @@ class HostBattleSDK {
|
|
|
81
90
|
const update = __classPrivateFieldGet(this, _HostBattleSDK_core, "f").progress([hostCommand, guestCommand]);
|
|
82
91
|
this.flowID = (0, nanoid_1.nanoid)();
|
|
83
92
|
const { dataChannel } = yield __classPrivateFieldGet(this, _HostBattleSDK_webRTCConnection, "f").getOrCreateConnection();
|
|
84
|
-
__classPrivateFieldSet(this, _HostBattleSDK_sendCommandPromise, (0, receive_send_command_1.receiveSendCommand)(
|
|
93
|
+
__classPrivateFieldSet(this, _HostBattleSDK_sendCommandPromise, (0, receive_send_command_1.receiveSendCommand)({
|
|
94
|
+
dataChannel,
|
|
95
|
+
flowID: this.flowID,
|
|
96
|
+
signal,
|
|
97
|
+
}), "f");
|
|
85
98
|
try {
|
|
86
99
|
(0, host_message_1.sendHostMessage)(dataChannel, {
|
|
87
100
|
type: "battle-progressed",
|
|
@@ -105,4 +118,4 @@ class HostBattleSDK {
|
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
120
|
exports.HostBattleSDK = HostBattleSDK;
|
|
108
|
-
_HostBattleSDK_core = new WeakMap(), _HostBattleSDK_webRTCConnection = new WeakMap(), _HostBattleSDK_sendCommandPromise = new WeakMap(), _HostBattleSDK_sendExceptionSubject = new WeakMap();
|
|
121
|
+
_HostBattleSDK_core = new WeakMap(), _HostBattleSDK_webRTCConnection = new WeakMap(), _HostBattleSDK_sendCommandPromise = new WeakMap(), _HostBattleSDK_sendExceptionSubject = new WeakMap(), _HostBattleSDK_abortManager = new WeakMap();
|
package/lib/sdk/{host-webrtc-connection-manager.js → host/host-webrtc-connection-manager.js}
RENAMED
|
@@ -22,7 +22,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var _HostWebRTCConnectionManager_authToken, _HostWebRTCConnectionManager_connection, _HostWebRTCConnectionManager_anonymousBackendApiURL, _HostWebRTCConnectionManager_coturnDomainName;
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.HostWebRTCConnectionManager = void 0;
|
|
25
|
-
const create_rtc_peer_connection_1 = require("
|
|
25
|
+
const create_rtc_peer_connection_1 = require("../create-rtc-peer-connection");
|
|
26
26
|
/** ホストのWebRTCコネクション管理 */
|
|
27
27
|
class HostWebRTCConnectionManager {
|
|
28
28
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ArmdozerId, PilotId } from "gbraver-burst-core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AbortManager } from "../../abort-controller/abort-manager";
|
|
3
|
+
import { AnonymousBattleSDK } from "../anonymous-battle-sdk";
|
|
4
|
+
import { FrontendLogManager } from "../frontend-log-manager";
|
|
5
|
+
import { WebSocketConnectionManager } from "../websocket-connection-manager";
|
|
4
6
|
import { HostWebRTCConnectionManager } from "./host-webrtc-connection-manager";
|
|
5
|
-
import { WebSocketConnectionManager } from "./websocket-connection-manager";
|
|
6
7
|
/** ローカルWebRTC ルーム */
|
|
7
8
|
export type LocalWebRTCRoom = {
|
|
8
9
|
/** ルームID */
|
|
@@ -26,6 +27,7 @@ export declare class LocalWebRTCRoomImpl implements LocalWebRTCRoom {
|
|
|
26
27
|
* @param options.webRTCConnection WebRTCコネクションマネジャー
|
|
27
28
|
* @param options.websocketConnection WebSocketコネクションマネジャー
|
|
28
29
|
* @param options.frontendLog フロントエンドログマネジャー
|
|
30
|
+
* @param options.abortManager アボート管理オブジェクト
|
|
29
31
|
*/
|
|
30
32
|
constructor(options: {
|
|
31
33
|
roomID: string;
|
|
@@ -35,6 +37,7 @@ export declare class LocalWebRTCRoomImpl implements LocalWebRTCRoom {
|
|
|
35
37
|
frontendLog: FrontendLogManager;
|
|
36
38
|
hostArmdozerId: ArmdozerId;
|
|
37
39
|
hostPilotId: PilotId;
|
|
40
|
+
abortManager: AbortManager;
|
|
38
41
|
});
|
|
39
42
|
/**
|
|
40
43
|
* マッチングするまで待機する
|