baltica 0.1.26 → 0.1.27
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/dist/client/client.d.ts
CHANGED
package/dist/client/client.js
CHANGED
|
@@ -49,11 +49,18 @@ class Client extends shared_1.Emitter {
|
|
|
49
49
|
/** Connect to the server and start sending/receiving packets. */
|
|
50
50
|
async connect() {
|
|
51
51
|
// Authenticate first before connecting to raknet
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
try {
|
|
53
|
+
if (this.options.offline) {
|
|
54
|
+
await (0, shared_1.createOfflineSession)(this);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
await (0, shared_1.authenticate)(this);
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
catch (error) {
|
|
61
|
+
// Clean up raknet on auth failure to prevent hanging process
|
|
62
|
+
this.destroy();
|
|
63
|
+
throw error;
|
|
57
64
|
}
|
|
58
65
|
this.sessionReady = true;
|
|
59
66
|
await this.raknet.connect();
|
|
@@ -230,5 +237,22 @@ class Client extends shared_1.Emitter {
|
|
|
230
237
|
raknet_1.Logger.debug(`Queueing packet ${packet instanceof protocol_1.DataPacket ? packet.constructor.name : "Buffer"}`);
|
|
231
238
|
this.sendPacket(packet, raknet_1.Priority.High);
|
|
232
239
|
}
|
|
240
|
+
/** Fully destroy the client and clean up all resources */
|
|
241
|
+
destroy() {
|
|
242
|
+
this.cleanup();
|
|
243
|
+
if (this.raknet instanceof worker_1.WorkerClient) {
|
|
244
|
+
this.raknet.dispose();
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
// RaknetClient - call disconnect which should clean up internal timers
|
|
248
|
+
try {
|
|
249
|
+
this.raknet.disconnect();
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// Ignore errors during cleanup
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
super.destroy();
|
|
256
|
+
}
|
|
233
257
|
}
|
|
234
258
|
exports.Client = Client;
|
package/dist/shared/auth.js
CHANGED
|
@@ -64,7 +64,9 @@ async function createOfflineSession(client) {
|
|
|
64
64
|
raknet_1.Logger.info("Offline session created");
|
|
65
65
|
}
|
|
66
66
|
catch (error) {
|
|
67
|
-
|
|
67
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
68
|
+
raknet_1.Logger.error(`Error while creating offline session: ${err.message}`);
|
|
69
|
+
client.emit("error", err);
|
|
68
70
|
throw error;
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -88,7 +90,9 @@ async function authenticate(client) {
|
|
|
88
90
|
client.emit("session");
|
|
89
91
|
}
|
|
90
92
|
catch (error) {
|
|
91
|
-
|
|
93
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
94
|
+
raknet_1.Logger.error(`Authentication failed: ${err.message}`);
|
|
95
|
+
client.emit("error", err);
|
|
92
96
|
throw error;
|
|
93
97
|
}
|
|
94
98
|
}
|
|
@@ -149,8 +153,10 @@ async function authenticateWithEmailPassword(client) {
|
|
|
149
153
|
client.emit("session");
|
|
150
154
|
}
|
|
151
155
|
catch (error) {
|
|
152
|
-
|
|
153
|
-
raknet_1.Logger.
|
|
156
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
157
|
+
raknet_1.Logger.error(`Email/password authentication failed: ${err.message}`);
|
|
158
|
+
raknet_1.Logger.warn("Make sure you have an xbox profile created!");
|
|
159
|
+
client.emit("error", err);
|
|
154
160
|
throw error;
|
|
155
161
|
}
|
|
156
162
|
}
|