bedrock-portal 0.0.7 → 0.0.9
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/package.json +2 -2
- package/src/index.js +18 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bedrock-portal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Creates a joinable session in Minecraft Bedrock Edition that can route players to their a specified host",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"axios": "^1.0.0",
|
|
21
21
|
"uuid": "^9.0.0",
|
|
22
|
-
"xbox-rta": "^0.0.
|
|
22
|
+
"xbox-rta": "^0.0.8"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"bedrock-portal": "file:.",
|
package/src/index.js
CHANGED
|
@@ -39,7 +39,6 @@ module.exports = class BedrockPortal extends EventEmitter {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async start() {
|
|
42
|
-
|
|
43
42
|
this.sessionOwner = await this.#rest.getXboxProfile('me');
|
|
44
43
|
|
|
45
44
|
if (!this.options.disableAltCheck) {
|
|
@@ -51,6 +50,16 @@ module.exports = class BedrockPortal extends EventEmitter {
|
|
|
51
50
|
|
|
52
51
|
const connectionId = await this.#rta.subscribe('https://sessiondirectory.xboxlive.com/connections/').then(e => e.data.ConnectionId);
|
|
53
52
|
|
|
53
|
+
const session = await this.createAndPublishSession(connectionId);
|
|
54
|
+
|
|
55
|
+
await this.#handleSessionEvents();
|
|
56
|
+
|
|
57
|
+
return session;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async createAndPublishSession(connectionId) {
|
|
61
|
+
this.players = [];
|
|
62
|
+
|
|
54
63
|
await this.updateSession(this.#createSessionBody(connectionId));
|
|
55
64
|
|
|
56
65
|
debug(`Created session, name: ${this.session.name}`);
|
|
@@ -61,8 +70,6 @@ module.exports = class BedrockPortal extends EventEmitter {
|
|
|
61
70
|
|
|
62
71
|
await this.updateSession({ properties: session.properties });
|
|
63
72
|
|
|
64
|
-
await this.#handleSessionEvents();
|
|
65
|
-
|
|
66
73
|
debug(`Published session, name: ${this.session.name}`);
|
|
67
74
|
|
|
68
75
|
return session;
|
|
@@ -135,7 +142,14 @@ module.exports = class BedrockPortal extends EventEmitter {
|
|
|
135
142
|
async #handleSessionEvents() {
|
|
136
143
|
this.#rta.on('reconnect', async () => {
|
|
137
144
|
const connectionId = await this.#rta.subscribe('https://sessiondirectory.xboxlive.com/connections/').then(e => e.data.ConnectionId);
|
|
138
|
-
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
await this.updateConnection(connectionId);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
debug('Failed to update connection, session may have been abandoned', e);
|
|
151
|
+
await this.createAndPublishSession(connectionId);
|
|
152
|
+
}
|
|
139
153
|
});
|
|
140
154
|
|
|
141
155
|
this.#rta.on('event', async ({ type, subId, data }) => {
|