@gbraver-burst-network/browser-sdk 1.6.3 → 1.8.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/src/browser-sdk/browser-sdk.d.ts +3 -2
- package/lib/src/browser-sdk/browser-sdk.js +85 -62
- package/lib/src/browser-sdk/create-battle-sdk-from-battle-start.d.ts +9 -0
- package/lib/src/browser-sdk/create-battle-sdk-from-battle-start.js +22 -0
- package/lib/src/browser-sdk/private-match-room-sdk.d.ts +16 -0
- package/lib/src/browser-sdk/private-match-room-sdk.js +49 -0
- package/lib/src/request/create-private-match-room.d.ts +9 -0
- package/lib/src/{response/websocket-api-response.js → request/create-private-match-room.js} +0 -0
- package/lib/src/request/enter-private-match-room.d.ts +12 -0
- package/lib/src/request/enter-private-match-room.js +2 -0
- package/lib/src/request/private-match-make-polling.d.ts +7 -0
- package/lib/src/request/private-match-make-polling.js +2 -0
- package/lib/src/request/request.d.ts +4 -1
- package/lib/src/response/cloud-not-private-match-making.d.ts +11 -0
- package/lib/src/response/cloud-not-private-match-making.js +20 -0
- package/lib/src/response/created-private-match-room.d.ts +13 -0
- package/lib/src/response/created-private-match-room.js +22 -0
- package/lib/src/response/reject-private-match-entry.d.ts +11 -0
- package/lib/src/response/reject-private-match-entry.js +18 -0
- package/lib/src/websocket/create-private-match-room.d.ts +10 -0
- package/lib/src/websocket/create-private-match-room.js +27 -0
- package/lib/src/websocket/enter-private-match-room.d.ts +13 -0
- package/lib/src/websocket/enter-private-match-room.js +36 -0
- package/lib/src/websocket/private-match-make-polling.d.ts +9 -0
- package/lib/src/websocket/private-match-make-polling.js +62 -0
- package/lib/src/websocket/send-command.js +11 -11
- package/lib/test/src/response/cloud-not-private-match-making.test.d.ts +1 -0
- package/lib/test/src/response/cloud-not-private-match-making.test.js +24 -0
- package/lib/test/src/response/parse-created-private-match-room.test.d.ts +1 -0
- package/lib/test/src/response/parse-created-private-match-room.test.js +25 -0
- package/lib/test/src/response/parse-reject-private-match-entry.test.d.ts +1 -0
- package/lib/test/src/response/parse-reject-private-match-entry.test.js +24 -0
- package/package.json +21 -18
- package/lib/src/response/websocket-api-response.d.ts +0 -11
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { CasualMatch, LoggedInUserDelete, LoginCheck, Logout, MailVerify, Ping, UniversalLogin, UserMailGet, UserNameGet, UserPictureGet, WebsocketDisconnect, WebsocketErrorNotifier
|
|
1
|
+
import type { CasualMatch, LoggedInUserDelete, LoginCheck, Logout, MailVerify, Ping, PrivateMatchRoomEnter, UniversalLogin, UserMailGet, UserNameGet, UserPictureGet, WebsocketDisconnect, WebsocketErrorNotifier } from "@gbraver-burst-network/browser-core";
|
|
2
|
+
import { PrivateMatchCreate } from "@gbraver-burst-network/browser-core/src";
|
|
2
3
|
/** ブラウザSDK */
|
|
3
|
-
export interface BrowserSDK extends UniversalLogin, LoginCheck, Logout, Ping, CasualMatch, UserNameGet, UserPictureGet, UserMailGet, MailVerify, LoggedInUserDelete, WebsocketDisconnect, WebsocketErrorNotifier,
|
|
4
|
+
export interface BrowserSDK extends UniversalLogin, LoginCheck, Logout, Ping, CasualMatch, UserNameGet, UserPictureGet, UserMailGet, MailVerify, LoggedInUserDelete, WebsocketDisconnect, WebsocketErrorNotifier, PrivateMatchCreate, PrivateMatchRoomEnter {
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
6
7
|
* GブレイバーバーストブラウザSDKを生成する
|
|
@@ -8,6 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
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");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _BrowserSDKImpl_instances, _BrowserSDKImpl_ownURL, _BrowserSDKImpl_restAPIURL, _BrowserSDKImpl_websocketAPIURL, _BrowserSDKImpl_auth0Client, _BrowserSDKImpl_websocket, _BrowserSDKImpl_websocketError, _BrowserSDKImpl_websocketSubscriptions, _BrowserSDKImpl_getOrCreateWebSocket;
|
|
11
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
24
|
exports.createBrowserSDK = void 0;
|
|
13
25
|
const rxjs_1 = require("rxjs");
|
|
@@ -15,9 +27,12 @@ const client_1 = require("../auth0/client");
|
|
|
15
27
|
const login_redirect_1 = require("../auth0/login-redirect");
|
|
16
28
|
const delete_user_1 = require("../http-request/delete-user");
|
|
17
29
|
const connect_1 = require("../websocket/connect");
|
|
30
|
+
const create_private_match_room_1 = require("../websocket/create-private-match-room");
|
|
18
31
|
const enter_casual_match_1 = require("../websocket/enter-casual-match");
|
|
32
|
+
const enter_private_match_room_1 = require("../websocket/enter-private-match-room");
|
|
19
33
|
const ping_1 = require("../websocket/ping");
|
|
20
|
-
const
|
|
34
|
+
const create_battle_sdk_from_battle_start_1 = require("./create-battle-sdk-from-battle-start");
|
|
35
|
+
const private_match_room_sdk_1 = require("./private-match-room-sdk");
|
|
21
36
|
/** ブラウザSDK実装 */
|
|
22
37
|
class BrowserSDKImpl {
|
|
23
38
|
/**
|
|
@@ -29,14 +44,21 @@ class BrowserSDKImpl {
|
|
|
29
44
|
* @param auth0Client auth0クライアント
|
|
30
45
|
*/
|
|
31
46
|
constructor(ownURL, restAPIURL, websocketAPIURL, auth0Client) {
|
|
32
|
-
this
|
|
33
|
-
this
|
|
34
|
-
this
|
|
35
|
-
this
|
|
36
|
-
this
|
|
37
|
-
this
|
|
38
|
-
this
|
|
39
|
-
this
|
|
47
|
+
_BrowserSDKImpl_instances.add(this);
|
|
48
|
+
_BrowserSDKImpl_ownURL.set(this, void 0);
|
|
49
|
+
_BrowserSDKImpl_restAPIURL.set(this, void 0);
|
|
50
|
+
_BrowserSDKImpl_websocketAPIURL.set(this, void 0);
|
|
51
|
+
_BrowserSDKImpl_auth0Client.set(this, void 0);
|
|
52
|
+
_BrowserSDKImpl_websocket.set(this, void 0);
|
|
53
|
+
_BrowserSDKImpl_websocketError.set(this, void 0);
|
|
54
|
+
_BrowserSDKImpl_websocketSubscriptions.set(this, void 0);
|
|
55
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_ownURL, ownURL, "f");
|
|
56
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_restAPIURL, restAPIURL, "f");
|
|
57
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_websocketAPIURL, websocketAPIURL, "f");
|
|
58
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_auth0Client, auth0Client, "f");
|
|
59
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_websocket, null, "f");
|
|
60
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_websocketError, new rxjs_1.Subject(), "f");
|
|
61
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_websocketSubscriptions, [], "f");
|
|
40
62
|
}
|
|
41
63
|
/** @override */
|
|
42
64
|
isLoginSuccessRedirect() {
|
|
@@ -45,30 +67,30 @@ class BrowserSDKImpl {
|
|
|
45
67
|
/** @override */
|
|
46
68
|
afterLoginSuccess() {
|
|
47
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
yield this.
|
|
70
|
+
yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").handleRedirectCallback();
|
|
49
71
|
(0, login_redirect_1.clearLoginHistory)();
|
|
50
72
|
});
|
|
51
73
|
}
|
|
52
74
|
/** @override */
|
|
53
75
|
gotoLoginPage() {
|
|
54
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
yield this.
|
|
77
|
+
yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").loginWithRedirect({
|
|
56
78
|
authorizationParams: {
|
|
57
|
-
redirect_uri: this
|
|
79
|
+
redirect_uri: __classPrivateFieldGet(this, _BrowserSDKImpl_ownURL, "f"),
|
|
58
80
|
},
|
|
59
81
|
});
|
|
60
82
|
});
|
|
61
83
|
}
|
|
62
84
|
/** @override */
|
|
63
85
|
isLogin() {
|
|
64
|
-
return this.
|
|
86
|
+
return __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").isAuthenticated();
|
|
65
87
|
}
|
|
66
88
|
/** @override */
|
|
67
89
|
logout() {
|
|
68
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
yield this.
|
|
91
|
+
yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").logout({
|
|
70
92
|
logoutParams: {
|
|
71
|
-
returnTo: this
|
|
93
|
+
returnTo: __classPrivateFieldGet(this, _BrowserSDKImpl_ownURL, "f"),
|
|
72
94
|
},
|
|
73
95
|
});
|
|
74
96
|
});
|
|
@@ -77,7 +99,7 @@ class BrowserSDKImpl {
|
|
|
77
99
|
getUserName() {
|
|
78
100
|
var _a;
|
|
79
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const user = yield this.
|
|
102
|
+
const user = yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").getUser();
|
|
81
103
|
return (_a = user === null || user === void 0 ? void 0 : user.nickname) !== null && _a !== void 0 ? _a : "";
|
|
82
104
|
});
|
|
83
105
|
}
|
|
@@ -85,7 +107,7 @@ class BrowserSDKImpl {
|
|
|
85
107
|
getUserPictureURL() {
|
|
86
108
|
var _a;
|
|
87
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
const user = yield this.
|
|
110
|
+
const user = yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").getUser();
|
|
89
111
|
return (_a = user === null || user === void 0 ? void 0 : user.picture) !== null && _a !== void 0 ? _a : "";
|
|
90
112
|
});
|
|
91
113
|
}
|
|
@@ -93,7 +115,7 @@ class BrowserSDKImpl {
|
|
|
93
115
|
getMail() {
|
|
94
116
|
var _a;
|
|
95
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const user = yield this.
|
|
118
|
+
const user = yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").getUser();
|
|
97
119
|
return (_a = user === null || user === void 0 ? void 0 : user.email) !== null && _a !== void 0 ? _a : "";
|
|
98
120
|
});
|
|
99
121
|
}
|
|
@@ -101,21 +123,21 @@ class BrowserSDKImpl {
|
|
|
101
123
|
isMailVerified() {
|
|
102
124
|
var _a;
|
|
103
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const user = yield this.
|
|
126
|
+
const user = yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").getUser();
|
|
105
127
|
return (_a = user === null || user === void 0 ? void 0 : user.email_verified) !== null && _a !== void 0 ? _a : false;
|
|
106
128
|
});
|
|
107
129
|
}
|
|
108
130
|
/** @override */
|
|
109
131
|
deleteLoggedInUser() {
|
|
110
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
const accessToken = yield this.
|
|
112
|
-
yield (0, delete_user_1.deleteLoggedInUser)(this
|
|
133
|
+
const accessToken = yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").getTokenSilently();
|
|
134
|
+
yield (0, delete_user_1.deleteLoggedInUser)(__classPrivateFieldGet(this, _BrowserSDKImpl_restAPIURL, "f"), accessToken);
|
|
113
135
|
});
|
|
114
136
|
}
|
|
115
137
|
/** @override */
|
|
116
138
|
ping() {
|
|
117
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
const websocket = yield this.
|
|
140
|
+
const websocket = yield __classPrivateFieldGet(this, _BrowserSDKImpl_instances, "m", _BrowserSDKImpl_getOrCreateWebSocket).call(this);
|
|
119
141
|
const resp = yield (0, ping_1.ping)(websocket);
|
|
120
142
|
return resp.message;
|
|
121
143
|
});
|
|
@@ -123,60 +145,61 @@ class BrowserSDKImpl {
|
|
|
123
145
|
/** @override */
|
|
124
146
|
startCasualMatch(armdozerId, pilotId) {
|
|
125
147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const websocket = yield this.
|
|
148
|
+
const websocket = yield __classPrivateFieldGet(this, _BrowserSDKImpl_instances, "m", _BrowserSDKImpl_getOrCreateWebSocket).call(this);
|
|
127
149
|
const resp = yield (0, enter_casual_match_1.enterCasualMatch)(websocket, armdozerId, pilotId);
|
|
128
|
-
return
|
|
129
|
-
player: resp.player,
|
|
130
|
-
enemy: resp.enemy,
|
|
131
|
-
initialState: resp.stateHistory,
|
|
132
|
-
battleID: resp.battleID,
|
|
133
|
-
initialFlowID: resp.flowID,
|
|
134
|
-
isPoller: resp.isPoller,
|
|
135
|
-
websocket,
|
|
136
|
-
});
|
|
150
|
+
return (0, create_battle_sdk_from_battle_start_1.createBattleSDKFromBattleStart)(resp, websocket);
|
|
137
151
|
});
|
|
138
152
|
}
|
|
139
153
|
/** @override */
|
|
140
|
-
|
|
154
|
+
createPrivateMatchRoom(armdozerId, pilotId) {
|
|
141
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
this
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
v.unsubscribe();
|
|
146
|
-
});
|
|
147
|
-
this._websocketSubscriptions = [];
|
|
156
|
+
const websocket = yield __classPrivateFieldGet(this, _BrowserSDKImpl_instances, "m", _BrowserSDKImpl_getOrCreateWebSocket).call(this);
|
|
157
|
+
const resp = yield (0, create_private_match_room_1.createPrivateMatchRoom)(websocket, armdozerId, pilotId);
|
|
158
|
+
return new private_match_room_sdk_1.PrivateMatchRoomSDK(resp.roomID, websocket);
|
|
148
159
|
});
|
|
149
160
|
}
|
|
150
161
|
/** @override */
|
|
151
|
-
|
|
152
|
-
return this
|
|
162
|
+
enterPrivateMatchRoom(roomID, armdozerId, pilotId) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const websocket = yield __classPrivateFieldGet(this, _BrowserSDKImpl_instances, "m", _BrowserSDKImpl_getOrCreateWebSocket).call(this);
|
|
165
|
+
const resp = yield (0, enter_private_match_room_1.enterPrivateMatchRoom)(websocket, roomID, armdozerId, pilotId);
|
|
166
|
+
if (resp.action !== "battle-start") {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
return (0, create_battle_sdk_from_battle_start_1.createBattleSDKFromBattleStart)(resp, websocket);
|
|
170
|
+
});
|
|
153
171
|
}
|
|
154
172
|
/** @override */
|
|
155
|
-
|
|
156
|
-
return this._websocketUnintentionalCloseNotifier;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* WebSocketクライアントの取得を行う
|
|
160
|
-
* WebSocketクライアントが存在しない場合は、本メソッド内で生成してから返す
|
|
161
|
-
*
|
|
162
|
-
* @return 取得、生成結果
|
|
163
|
-
*/
|
|
164
|
-
_getOrCreateWebSocket() {
|
|
173
|
+
disconnectWebsocket() {
|
|
165
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this
|
|
172
|
-
(0, rxjs_1.fromEvent)(websocket, "error").subscribe(this._websocketError),
|
|
173
|
-
(0, rxjs_1.fromEvent)(websocket, "close").subscribe(this._websocketError),
|
|
174
|
-
];
|
|
175
|
-
this._websocket = websocket;
|
|
176
|
-
return websocket;
|
|
175
|
+
__classPrivateFieldGet(this, _BrowserSDKImpl_websocket, "f") && __classPrivateFieldGet(this, _BrowserSDKImpl_websocket, "f").close();
|
|
176
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_websocket, null, "f");
|
|
177
|
+
__classPrivateFieldGet(this, _BrowserSDKImpl_websocketSubscriptions, "f").forEach((v) => {
|
|
178
|
+
v.unsubscribe();
|
|
179
|
+
});
|
|
180
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_websocketSubscriptions, [], "f");
|
|
177
181
|
});
|
|
178
182
|
}
|
|
183
|
+
/** @override */
|
|
184
|
+
websocketErrorNotifier() {
|
|
185
|
+
return __classPrivateFieldGet(this, _BrowserSDKImpl_websocketError, "f");
|
|
186
|
+
}
|
|
179
187
|
}
|
|
188
|
+
_BrowserSDKImpl_ownURL = new WeakMap(), _BrowserSDKImpl_restAPIURL = new WeakMap(), _BrowserSDKImpl_websocketAPIURL = new WeakMap(), _BrowserSDKImpl_auth0Client = new WeakMap(), _BrowserSDKImpl_websocket = new WeakMap(), _BrowserSDKImpl_websocketError = new WeakMap(), _BrowserSDKImpl_websocketSubscriptions = new WeakMap(), _BrowserSDKImpl_instances = new WeakSet(), _BrowserSDKImpl_getOrCreateWebSocket = function _BrowserSDKImpl_getOrCreateWebSocket() {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
if (__classPrivateFieldGet(this, _BrowserSDKImpl_websocket, "f")) {
|
|
191
|
+
return __classPrivateFieldGet(this, _BrowserSDKImpl_websocket, "f");
|
|
192
|
+
}
|
|
193
|
+
const accessToken = yield __classPrivateFieldGet(this, _BrowserSDKImpl_auth0Client, "f").getTokenSilently();
|
|
194
|
+
const websocket = yield (0, connect_1.connect)(`${__classPrivateFieldGet(this, _BrowserSDKImpl_websocketAPIURL, "f")}?token=${accessToken}`);
|
|
195
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_websocketSubscriptions, [
|
|
196
|
+
(0, rxjs_1.fromEvent)(websocket, "error").subscribe(__classPrivateFieldGet(this, _BrowserSDKImpl_websocketError, "f")),
|
|
197
|
+
(0, rxjs_1.fromEvent)(websocket, "close").subscribe(__classPrivateFieldGet(this, _BrowserSDKImpl_websocketError, "f")),
|
|
198
|
+
], "f");
|
|
199
|
+
__classPrivateFieldSet(this, _BrowserSDKImpl_websocket, websocket, "f");
|
|
200
|
+
return websocket;
|
|
201
|
+
});
|
|
202
|
+
};
|
|
180
203
|
/**
|
|
181
204
|
* GブレイバーバーストブラウザSDKを生成する
|
|
182
205
|
*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BattleStart } from "../response/battle-start";
|
|
2
|
+
import { BattleSDK } from "./battle-sdk";
|
|
3
|
+
/**
|
|
4
|
+
* BattleStartからBattleSDKを生成する
|
|
5
|
+
* @param battleStart BattleStartのデータ
|
|
6
|
+
* @param websocket websocketクライアント
|
|
7
|
+
* @return 生成結果
|
|
8
|
+
*/
|
|
9
|
+
export declare function createBattleSDKFromBattleStart(battleStart: BattleStart, websocket: WebSocket): BattleSDK;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBattleSDKFromBattleStart = void 0;
|
|
4
|
+
const battle_sdk_1 = require("./battle-sdk");
|
|
5
|
+
/**
|
|
6
|
+
* BattleStartからBattleSDKを生成する
|
|
7
|
+
* @param battleStart BattleStartのデータ
|
|
8
|
+
* @param websocket websocketクライアント
|
|
9
|
+
* @return 生成結果
|
|
10
|
+
*/
|
|
11
|
+
function createBattleSDKFromBattleStart(battleStart, websocket) {
|
|
12
|
+
return new battle_sdk_1.BattleSDK({
|
|
13
|
+
player: battleStart.player,
|
|
14
|
+
enemy: battleStart.enemy,
|
|
15
|
+
initialState: battleStart.stateHistory,
|
|
16
|
+
battleID: battleStart.battleID,
|
|
17
|
+
initialFlowID: battleStart.flowID,
|
|
18
|
+
isPoller: battleStart.isPoller,
|
|
19
|
+
websocket,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.createBattleSDKFromBattleStart = createBattleSDKFromBattleStart;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PrivateMatchRoom } from "@gbraver-burst-network/browser-core";
|
|
2
|
+
import { Battle, PrivateMatchRoomID } from "@gbraver-burst-network/browser-core/src";
|
|
3
|
+
/** プライベートマッチSDK */
|
|
4
|
+
export declare class PrivateMatchRoomSDK implements PrivateMatchRoom {
|
|
5
|
+
#private;
|
|
6
|
+
/** @override */
|
|
7
|
+
roomID: PrivateMatchRoomID;
|
|
8
|
+
/**
|
|
9
|
+
* コンストラクタ
|
|
10
|
+
* @param roomID ルームID
|
|
11
|
+
* @param websocket websocketクライアント
|
|
12
|
+
*/
|
|
13
|
+
constructor(roomID: PrivateMatchRoomID, websocket: WebSocket);
|
|
14
|
+
/** @override */
|
|
15
|
+
waitUntilMatching(): Promise<Battle>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
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");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _PrivateMatchRoomSDK_websocket;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.PrivateMatchRoomSDK = void 0;
|
|
25
|
+
const private_match_make_polling_1 = require("../websocket/private-match-make-polling");
|
|
26
|
+
const create_battle_sdk_from_battle_start_1 = require("./create-battle-sdk-from-battle-start");
|
|
27
|
+
/** プライベートマッチSDK */
|
|
28
|
+
class PrivateMatchRoomSDK {
|
|
29
|
+
/**
|
|
30
|
+
* コンストラクタ
|
|
31
|
+
* @param roomID ルームID
|
|
32
|
+
* @param websocket websocketクライアント
|
|
33
|
+
*/
|
|
34
|
+
constructor(roomID, websocket) {
|
|
35
|
+
/** websocketクライアント */
|
|
36
|
+
_PrivateMatchRoomSDK_websocket.set(this, void 0);
|
|
37
|
+
this.roomID = roomID;
|
|
38
|
+
__classPrivateFieldSet(this, _PrivateMatchRoomSDK_websocket, websocket, "f");
|
|
39
|
+
}
|
|
40
|
+
/** @override */
|
|
41
|
+
waitUntilMatching() {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const resp = yield (0, private_match_make_polling_1.privateMatchMakePolling)(__classPrivateFieldGet(this, _PrivateMatchRoomSDK_websocket, "f"), this.roomID);
|
|
44
|
+
return (0, create_battle_sdk_from_battle_start_1.createBattleSDKFromBattleStart)(resp, __classPrivateFieldGet(this, _PrivateMatchRoomSDK_websocket, "f"));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.PrivateMatchRoomSDK = PrivateMatchRoomSDK;
|
|
49
|
+
_PrivateMatchRoomSDK_websocket = new WeakMap();
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PrivateMatchRoomID } from "@gbraver-burst-network/browser-core";
|
|
2
|
+
import { ArmDozerId, PilotId } from "gbraver-burst-core";
|
|
3
|
+
/** プライベートマッチルームエントリ */
|
|
4
|
+
export type EnterPrivateMatchRoom = {
|
|
5
|
+
action: "enter-private-match-room";
|
|
6
|
+
/** ルームID */
|
|
7
|
+
roomID: PrivateMatchRoomID;
|
|
8
|
+
/** 選択したアームドーザID */
|
|
9
|
+
armdozerId: ArmDozerId;
|
|
10
|
+
/** 選択したパイロットID */
|
|
11
|
+
pilotId: PilotId;
|
|
12
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { BattleProgressPolling } from "./battle-progress-polling";
|
|
2
|
+
import { CreatePrivateMatchRoom } from "./create-private-match-room";
|
|
2
3
|
import type { EnterCasualMatch } from "./enter-casual-match";
|
|
4
|
+
import { EnterPrivateMatchRoom } from "./enter-private-match-room";
|
|
3
5
|
import type { Ping } from "./ping";
|
|
6
|
+
import { PrivateMatchMakePolling } from "./private-match-make-polling";
|
|
4
7
|
import type { SendCommand } from "./send-command";
|
|
5
8
|
/** APIサーバへのリクエスト */
|
|
6
|
-
export type APIServerRequest = Ping | EnterCasualMatch | SendCommand | BattleProgressPolling;
|
|
9
|
+
export type APIServerRequest = Ping | EnterCasualMatch | SendCommand | BattleProgressPolling | CreatePrivateMatchRoom | EnterPrivateMatchRoom | PrivateMatchMakePolling;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** オーナーがプライベートマッチングできなかった */
|
|
2
|
+
export type CouldNotPrivateMatchMaking = {
|
|
3
|
+
action: "cloud-not-private-match-making";
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* 任意オブジェクトをCouldNotPrivateMatchMakingにパースする
|
|
7
|
+
* パースできない場合はnullを返す
|
|
8
|
+
* @param origin パース元
|
|
9
|
+
* @return パース結果
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseCouldNotPrivateMatchMaking(origin: any): CouldNotPrivateMatchMaking | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCouldNotPrivateMatchMaking = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 任意オブジェクトをCouldNotPrivateMatchMakingにパースする
|
|
6
|
+
* パースできない場合はnullを返す
|
|
7
|
+
* @param origin パース元
|
|
8
|
+
* @return パース結果
|
|
9
|
+
*/
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
+
function parseCouldNotPrivateMatchMaking(origin) {
|
|
12
|
+
/* eslint-enable */
|
|
13
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.action) === "cloud-not-private-match-making") {
|
|
14
|
+
return {
|
|
15
|
+
action: "cloud-not-private-match-making",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
exports.parseCouldNotPrivateMatchMaking = parseCouldNotPrivateMatchMaking;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** オーナーがプライベートマッチルーム作成に成功した */
|
|
2
|
+
export type CreatedPrivateMatchRoom = {
|
|
3
|
+
action: "created-private-match-room";
|
|
4
|
+
/** 作成したルームID */
|
|
5
|
+
roomID: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 任意オブジェクトをCreatedPrivateMatchRoomにパースする
|
|
9
|
+
* パースできない場合はnullを返す
|
|
10
|
+
* @param data パース元
|
|
11
|
+
* @return パース結果
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseCreatedPrivateMatchRoom(data: any): CreatedPrivateMatchRoom | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCreatedPrivateMatchRoom = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 任意オブジェクトをCreatedPrivateMatchRoomにパースする
|
|
6
|
+
* パースできない場合はnullを返す
|
|
7
|
+
* @param data パース元
|
|
8
|
+
* @return パース結果
|
|
9
|
+
*/
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
+
function parseCreatedPrivateMatchRoom(data) {
|
|
12
|
+
/* eslint-enable */
|
|
13
|
+
if ((data === null || data === void 0 ? void 0 : data.action) === "created-private-match-room" &&
|
|
14
|
+
typeof (data === null || data === void 0 ? void 0 : data.roomID) === "string") {
|
|
15
|
+
return {
|
|
16
|
+
action: "created-private-match-room",
|
|
17
|
+
roomID: data.roomID,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
exports.parseCreatedPrivateMatchRoom = parseCreatedPrivateMatchRoom;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** 何らかの理由でプライベートマッチに参加できなかった */
|
|
2
|
+
export type RejectPrivateMatchEntry = {
|
|
3
|
+
action: "reject-private-match-entry";
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* 任意オブジェクトをRejectPrivateMatchEntryにパースする
|
|
7
|
+
* パースできない場合はnullを返す
|
|
8
|
+
* @param data パース元となるオブジェクト
|
|
9
|
+
* @return パース結果
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseRejectPrivateMatchEntry(origin: any): RejectPrivateMatchEntry | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseRejectPrivateMatchEntry = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 任意オブジェクトをRejectPrivateMatchEntryにパースする
|
|
6
|
+
* パースできない場合はnullを返す
|
|
7
|
+
* @param data パース元となるオブジェクト
|
|
8
|
+
* @return パース結果
|
|
9
|
+
*/
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
+
function parseRejectPrivateMatchEntry(origin) {
|
|
12
|
+
/* eslint-enable */
|
|
13
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.action) === "reject-private-match-entry") {
|
|
14
|
+
return { action: "reject-private-match-entry" };
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
exports.parseRejectPrivateMatchEntry = parseRejectPrivateMatchEntry;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ArmDozerId, PilotId } from "gbraver-burst-core";
|
|
2
|
+
import { CreatedPrivateMatchRoom } from "../response/created-private-match-room";
|
|
3
|
+
/**
|
|
4
|
+
* プライベートマッチルームを生成する
|
|
5
|
+
* @param websocket websocketクライアント
|
|
6
|
+
* @param armdozerId 選択したアームドーザのID
|
|
7
|
+
* @param pilotId 選択したパイロットのID
|
|
8
|
+
* @return レスポンス
|
|
9
|
+
*/
|
|
10
|
+
export declare function createPrivateMatchRoom(websocket: WebSocket, armdozerId: ArmDozerId, pilotId: PilotId): Promise<CreatedPrivateMatchRoom>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPrivateMatchRoom = void 0;
|
|
4
|
+
const parse_1 = require("../json/parse");
|
|
5
|
+
const created_private_match_room_1 = require("../response/created-private-match-room");
|
|
6
|
+
const send_to_api_server_1 = require("./send-to-api-server");
|
|
7
|
+
const wait_until_1 = require("./wait-until");
|
|
8
|
+
/**
|
|
9
|
+
* プライベートマッチルームを生成する
|
|
10
|
+
* @param websocket websocketクライアント
|
|
11
|
+
* @param armdozerId 選択したアームドーザのID
|
|
12
|
+
* @param pilotId 選択したパイロットのID
|
|
13
|
+
* @return レスポンス
|
|
14
|
+
*/
|
|
15
|
+
function createPrivateMatchRoom(websocket, armdozerId, pilotId) {
|
|
16
|
+
(0, send_to_api_server_1.sendToAPIServer)(websocket, {
|
|
17
|
+
action: "create-private-match-room",
|
|
18
|
+
armdozerId,
|
|
19
|
+
pilotId,
|
|
20
|
+
});
|
|
21
|
+
return (0, wait_until_1.waitUntil)(websocket, (e, resolve) => {
|
|
22
|
+
const data = (0, parse_1.parseJSON)(e.data);
|
|
23
|
+
const response = (0, created_private_match_room_1.parseCreatedPrivateMatchRoom)(data);
|
|
24
|
+
response && resolve(response);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.createPrivateMatchRoom = createPrivateMatchRoom;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PrivateMatchRoomID } from "@gbraver-burst-network/browser-core";
|
|
2
|
+
import { ArmDozerId, PilotId } from "gbraver-burst-core";
|
|
3
|
+
import { BattleStart } from "../response/battle-start";
|
|
4
|
+
import { RejectPrivateMatchEntry } from "../response/reject-private-match-entry";
|
|
5
|
+
/**
|
|
6
|
+
* プライベートマッチルームに入室する
|
|
7
|
+
* @param websocket websocketクライアント
|
|
8
|
+
* @param roomID ルームID
|
|
9
|
+
* @param armdozerId アームドーザID
|
|
10
|
+
* @param pilotId パイロットID
|
|
11
|
+
* @return 入室結果
|
|
12
|
+
*/
|
|
13
|
+
export declare function enterPrivateMatchRoom(websocket: WebSocket, roomID: PrivateMatchRoomID, armdozerId: ArmDozerId, pilotId: PilotId): Promise<BattleStart | RejectPrivateMatchEntry>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enterPrivateMatchRoom = void 0;
|
|
4
|
+
const parse_1 = require("../json/parse");
|
|
5
|
+
const battle_start_1 = require("../response/battle-start");
|
|
6
|
+
const reject_private_match_entry_1 = require("../response/reject-private-match-entry");
|
|
7
|
+
const send_to_api_server_1 = require("./send-to-api-server");
|
|
8
|
+
const wait_until_1 = require("./wait-until");
|
|
9
|
+
/**
|
|
10
|
+
* プライベートマッチルームに入室する
|
|
11
|
+
* @param websocket websocketクライアント
|
|
12
|
+
* @param roomID ルームID
|
|
13
|
+
* @param armdozerId アームドーザID
|
|
14
|
+
* @param pilotId パイロットID
|
|
15
|
+
* @return 入室結果
|
|
16
|
+
*/
|
|
17
|
+
function enterPrivateMatchRoom(websocket, roomID, armdozerId, pilotId) {
|
|
18
|
+
(0, send_to_api_server_1.sendToAPIServer)(websocket, {
|
|
19
|
+
action: "enter-private-match-room",
|
|
20
|
+
roomID,
|
|
21
|
+
armdozerId,
|
|
22
|
+
pilotId,
|
|
23
|
+
});
|
|
24
|
+
return (0, wait_until_1.waitUntil)(websocket, (e, resolve) => {
|
|
25
|
+
const data = (0, parse_1.parseJSON)(e.data);
|
|
26
|
+
const battleStart = (0, battle_start_1.parseBattleStart)(data);
|
|
27
|
+
if (battleStart) {
|
|
28
|
+
resolve(battleStart);
|
|
29
|
+
}
|
|
30
|
+
const rejectPrivateMatchEntry = (0, reject_private_match_entry_1.parseRejectPrivateMatchEntry)(data);
|
|
31
|
+
if (rejectPrivateMatchEntry) {
|
|
32
|
+
resolve(rejectPrivateMatchEntry);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.enterPrivateMatchRoom = enterPrivateMatchRoom;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PrivateMatchRoomID } from "@gbraver-burst-network/browser-core";
|
|
2
|
+
import { BattleStart } from "../response/battle-start";
|
|
3
|
+
/**
|
|
4
|
+
* プライベートマッチングポーリング
|
|
5
|
+
* @param websocket websocketクライアント
|
|
6
|
+
* @param roomID ルームID
|
|
7
|
+
* @return APIサーバからのレスポンス
|
|
8
|
+
*/
|
|
9
|
+
export declare function privateMatchMakePolling(websocket: WebSocket, roomID: PrivateMatchRoomID): Promise<BattleStart>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.privateMatchMakePolling = void 0;
|
|
13
|
+
const parse_1 = require("../json/parse");
|
|
14
|
+
const battle_start_1 = require("../response/battle-start");
|
|
15
|
+
const cloud_not_private_match_making_1 = require("../response/cloud-not-private-match-making");
|
|
16
|
+
const wait_1 = require("../wait/wait");
|
|
17
|
+
const send_to_api_server_1 = require("./send-to-api-server");
|
|
18
|
+
const wait_until_1 = require("./wait-until");
|
|
19
|
+
/**
|
|
20
|
+
* プライベートマッチングポーリング
|
|
21
|
+
* @param websocket websocketクライアント
|
|
22
|
+
* @param roomID ルームID
|
|
23
|
+
* @return APIサーバからのレスポンス
|
|
24
|
+
*/
|
|
25
|
+
function privateMatchMakePolling(websocket, roomID) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const maxPollingCount = 200;
|
|
28
|
+
const pollingIntervalMilliSec = 3000;
|
|
29
|
+
let pollingCount = 1;
|
|
30
|
+
let lastPollingTime = 0;
|
|
31
|
+
const polling = () => {
|
|
32
|
+
pollingCount++;
|
|
33
|
+
lastPollingTime = Date.now();
|
|
34
|
+
(0, send_to_api_server_1.sendToAPIServer)(websocket, {
|
|
35
|
+
action: "private-match-make-polling",
|
|
36
|
+
roomID,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
polling();
|
|
40
|
+
return (0, wait_until_1.waitUntil)(websocket, (e, resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const data = (0, parse_1.parseJSON)(e.data);
|
|
42
|
+
const cloudNotPrivateMatchMaking = (0, cloud_not_private_match_making_1.parseCouldNotPrivateMatchMaking)(data);
|
|
43
|
+
const isOverPollingCount = maxPollingCount <= pollingCount;
|
|
44
|
+
if (cloudNotPrivateMatchMaking && isOverPollingCount) {
|
|
45
|
+
reject(new Error("max polling count over"));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (cloudNotPrivateMatchMaking) {
|
|
49
|
+
const pollingTime = Date.now() - lastPollingTime;
|
|
50
|
+
const waitTime = Math.max(pollingIntervalMilliSec - pollingTime, 0);
|
|
51
|
+
yield (0, wait_1.wait)(waitTime);
|
|
52
|
+
polling();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const battleStart = (0, battle_start_1.parseBattleStart)(data);
|
|
56
|
+
if (battleStart) {
|
|
57
|
+
resolve(battleStart);
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.privateMatchMakePolling = privateMatchMakePolling;
|
|
@@ -61,6 +61,17 @@ exports.sendCommand = sendCommand;
|
|
|
61
61
|
*/
|
|
62
62
|
function sendCommandWithPolling(websocket, battleID, flowID, command) {
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
(0, send_to_api_server_1.sendToAPIServer)(websocket, {
|
|
65
|
+
action: "send-command",
|
|
66
|
+
battleID,
|
|
67
|
+
flowID,
|
|
68
|
+
command,
|
|
69
|
+
});
|
|
70
|
+
yield (0, wait_until_1.waitUntil)(websocket, (e, resolve) => {
|
|
71
|
+
const data = (0, parse_1.parseJSON)(e.data);
|
|
72
|
+
const acceptCommand = (0, accept_command_1.parseAcceptCommand)(data);
|
|
73
|
+
acceptCommand && resolve(acceptCommand);
|
|
74
|
+
});
|
|
64
75
|
const maxPollingCount = 100;
|
|
65
76
|
const pollingIntervalMilliSec = 3000;
|
|
66
77
|
let pollingCount = 1;
|
|
@@ -74,17 +85,6 @@ function sendCommandWithPolling(websocket, battleID, flowID, command) {
|
|
|
74
85
|
flowID,
|
|
75
86
|
});
|
|
76
87
|
};
|
|
77
|
-
(0, send_to_api_server_1.sendToAPIServer)(websocket, {
|
|
78
|
-
action: "send-command",
|
|
79
|
-
battleID,
|
|
80
|
-
flowID,
|
|
81
|
-
command,
|
|
82
|
-
});
|
|
83
|
-
yield (0, wait_until_1.waitUntil)(websocket, (e, resolve) => {
|
|
84
|
-
const data = (0, parse_1.parseJSON)(e.data);
|
|
85
|
-
const acceptCommand = (0, accept_command_1.parseAcceptCommand)(data);
|
|
86
|
-
acceptCommand && resolve(acceptCommand);
|
|
87
|
-
});
|
|
88
88
|
battleProgressPolling();
|
|
89
89
|
return (0, wait_until_1.waitUntil)(websocket, (e, resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
const data = (0, parse_1.parseJSON)(e.data);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cloud_not_private_match_making_1 = require("../../../src/response/cloud-not-private-match-making");
|
|
4
|
+
test("CouldNotPrivateMatchMakingはパースできる", () => {
|
|
5
|
+
const data = {
|
|
6
|
+
action: "cloud-not-private-match-making",
|
|
7
|
+
};
|
|
8
|
+
expect((0, cloud_not_private_match_making_1.parseCouldNotPrivateMatchMaking)(data)).toEqual(data);
|
|
9
|
+
});
|
|
10
|
+
test("余計なプロパティがあってもパースできる", () => {
|
|
11
|
+
const origin = {
|
|
12
|
+
action: "cloud-not-private-match-making",
|
|
13
|
+
};
|
|
14
|
+
const data = Object.assign(Object.assign({}, origin), { propA: 1000, propB: "value" });
|
|
15
|
+
expect((0, cloud_not_private_match_making_1.parseCouldNotPrivateMatchMaking)(data)).toEqual(origin);
|
|
16
|
+
});
|
|
17
|
+
test("nullはパースできない", () => {
|
|
18
|
+
const data = null;
|
|
19
|
+
expect((0, cloud_not_private_match_making_1.parseCouldNotPrivateMatchMaking)(data)).toEqual(null);
|
|
20
|
+
});
|
|
21
|
+
test("undefinedはパースできない", () => {
|
|
22
|
+
const data = undefined;
|
|
23
|
+
expect((0, cloud_not_private_match_making_1.parseCouldNotPrivateMatchMaking)(data)).toEqual(null);
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const created_private_match_room_1 = require("../../../src/response/created-private-match-room");
|
|
4
|
+
test("CreatedPrivateMatchRoomはパースできる", () => {
|
|
5
|
+
const data = {
|
|
6
|
+
action: "created-private-match-room",
|
|
7
|
+
roomID: "test-room-id",
|
|
8
|
+
};
|
|
9
|
+
expect((0, created_private_match_room_1.parseCreatedPrivateMatchRoom)(data)).toEqual(data);
|
|
10
|
+
});
|
|
11
|
+
test("データ型が異なるとパースできない", () => {
|
|
12
|
+
const data = {
|
|
13
|
+
action: "created-private-match-room",
|
|
14
|
+
roomID: 1000,
|
|
15
|
+
};
|
|
16
|
+
expect((0, created_private_match_room_1.parseCreatedPrivateMatchRoom)(data)).toEqual(null);
|
|
17
|
+
});
|
|
18
|
+
test("nullはパースできない", () => {
|
|
19
|
+
const data = null;
|
|
20
|
+
expect((0, created_private_match_room_1.parseCreatedPrivateMatchRoom)(data)).toEqual(null);
|
|
21
|
+
});
|
|
22
|
+
test("undefinedはパースできない", () => {
|
|
23
|
+
const data = undefined;
|
|
24
|
+
expect((0, created_private_match_room_1.parseCreatedPrivateMatchRoom)(data)).toEqual(null);
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const reject_private_match_entry_1 = require("../../../src/response/reject-private-match-entry");
|
|
4
|
+
test("RejectPrivateMatchEntryはパースできる", () => {
|
|
5
|
+
const data = {
|
|
6
|
+
action: "reject-private-match-entry",
|
|
7
|
+
};
|
|
8
|
+
expect((0, reject_private_match_entry_1.parseRejectPrivateMatchEntry)(data)).toEqual(data);
|
|
9
|
+
});
|
|
10
|
+
test("余計なプロパティがあってもパースできる", () => {
|
|
11
|
+
const origin = {
|
|
12
|
+
action: "reject-private-match-entry",
|
|
13
|
+
};
|
|
14
|
+
const data = Object.assign(Object.assign({}, origin), { propA: 1000, propB: "value" });
|
|
15
|
+
expect((0, reject_private_match_entry_1.parseRejectPrivateMatchEntry)(data)).toEqual(origin);
|
|
16
|
+
});
|
|
17
|
+
test("nullはパースできない", () => {
|
|
18
|
+
const data = null;
|
|
19
|
+
expect((0, reject_private_match_entry_1.parseRejectPrivateMatchEntry)(data)).toEqual(null);
|
|
20
|
+
});
|
|
21
|
+
test("undefinedはパースできない", () => {
|
|
22
|
+
const data = undefined;
|
|
23
|
+
expect((0, reject_private_match_entry_1.parseRejectPrivateMatchEntry)(data)).toEqual(null);
|
|
24
|
+
});
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gbraver-burst-network/browser-sdk",
|
|
3
3
|
"description": "gbraver burst browser sdk",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"author": "Y.Takeuchi",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/kaidouji85/gbraver-burst-network/issues",
|
|
8
8
|
"email": "kaidouji85@gmail.com"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@auth0/auth0-spa-js": "^2.0.
|
|
12
|
-
"@gbraver-burst-network/browser-core": "^1.
|
|
13
|
-
"gbraver-burst-core": "^1.16.
|
|
11
|
+
"@auth0/auth0-spa-js": "^2.0.2",
|
|
12
|
+
"@gbraver-burst-network/browser-core": "^1.8.0",
|
|
13
|
+
"gbraver-burst-core": "^1.16.4",
|
|
14
14
|
"rxjs": "^7.8.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@types/jest": "^29.
|
|
18
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
19
|
-
"@typescript-eslint/parser": "^5.
|
|
17
|
+
"@types/jest": "^29.4.0",
|
|
18
|
+
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
|
19
|
+
"@typescript-eslint/parser": "^5.49.0",
|
|
20
20
|
"codehawk-cli": "^10.1.0",
|
|
21
|
-
"eslint": "^8.
|
|
21
|
+
"eslint": "^8.33.0",
|
|
22
22
|
"eslint-plugin-jest": "^27.2.1",
|
|
23
|
-
"eslint-plugin-simple-import-sort": "^
|
|
24
|
-
"jest": "^29.
|
|
23
|
+
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
24
|
+
"jest": "^29.4.1",
|
|
25
25
|
"npm-run-all": "^4.1.5",
|
|
26
|
-
"prettier": "2.8.
|
|
27
|
-
"rimraf": "^
|
|
28
|
-
"ts-jest": "^29.0.
|
|
26
|
+
"prettier": "2.8.3",
|
|
27
|
+
"rimraf": "^4.1.2",
|
|
28
|
+
"ts-jest": "^29.0.5",
|
|
29
29
|
"typescript": "^4.9.4",
|
|
30
30
|
"webpack": "^5.75.0",
|
|
31
31
|
"webpack-cli": "^5.0.1"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"files": [
|
|
34
34
|
"lib"
|
|
35
35
|
],
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "aef64e53855bb9f1ae46ab575312ec1978700fb5",
|
|
37
37
|
"homepage": "https://github.com/kaidouji85/gbraver-burst-network/tree/develop/packages/browser-sdk#readme",
|
|
38
38
|
"keywords": [
|
|
39
39
|
"browser",
|
|
@@ -44,14 +44,17 @@
|
|
|
44
44
|
"main": "lib/src/index.js",
|
|
45
45
|
"repository": "https://github.com/kaidouji85/gbraver-burst-network/tree/develop/packages/browser-sdk",
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "run-s clean
|
|
47
|
+
"build": "run-s clean transpile",
|
|
48
48
|
"clean": "rimraf lib",
|
|
49
49
|
"code-analysis": "codehawk src",
|
|
50
|
-
"code-format": "
|
|
50
|
+
"code-format": "run-s code-format:src code-format:test",
|
|
51
|
+
"code-format:src": "prettier --write src",
|
|
51
52
|
"code-format:test": "prettier --write test",
|
|
52
|
-
"lint": "
|
|
53
|
-
"lint-fix": "
|
|
53
|
+
"lint": "run-s lint:src lint:test",
|
|
54
|
+
"lint-fix": "run-s lint-fix:src lint-fix:test",
|
|
55
|
+
"lint-fix:src": "eslint --fix src",
|
|
54
56
|
"lint-fix:test": "eslint --fix test",
|
|
57
|
+
"lint:src": "eslint src",
|
|
55
58
|
"lint:test": "eslint test",
|
|
56
59
|
"test": "jest",
|
|
57
60
|
"transpile": "tsc -d --outDir lib",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AcceptCommand } from "./accept-command";
|
|
2
|
-
import type { BattleEnd } from "./battle-end";
|
|
3
|
-
import type { BattleProgressed } from "./battle-progressed";
|
|
4
|
-
import type { BattleStart } from "./battle-start";
|
|
5
|
-
import type { EnteredCasualMatch } from "./entered-casual-match";
|
|
6
|
-
import type { Error } from "./error";
|
|
7
|
-
import type { NotReadyBattleProgress } from "./not-ready-battle-progress";
|
|
8
|
-
import type { Pong } from "./pong";
|
|
9
|
-
import type { SuddenlyBattleEnd } from "./suddenly-battle-end";
|
|
10
|
-
/** APIサーバからのレスポンス */
|
|
11
|
-
export type WebsocketAPIResponse = Pong | EnteredCasualMatch | AcceptCommand | BattleStart | NotReadyBattleProgress | BattleProgressed | BattleEnd | SuddenlyBattleEnd | Error;
|