playsocketjs 1.0.3 → 1.0.4
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.
|
@@ -333,13 +333,14 @@ class PlaySocket {
|
|
|
333
333
|
*/
|
|
334
334
|
updateStorage(key, value) {
|
|
335
335
|
if (JSON.stringify(this.#storage[key]) === JSON.stringify(value)) return;
|
|
336
|
-
this.#storage[key] = value;
|
|
337
|
-
this.#triggerEvent("storageUpdated", { ...this.#storage });
|
|
338
336
|
this.#sendToServer({
|
|
339
337
|
type: 'room_storage_update',
|
|
340
338
|
key,
|
|
341
339
|
value
|
|
342
340
|
});
|
|
341
|
+
// Optimistic update AFTER sendToServer to preserve order if messages are being sent in the event callback
|
|
342
|
+
this.#storage[key] = value;
|
|
343
|
+
this.#triggerEvent("storageUpdated", { ...this.#storage });
|
|
343
344
|
}
|
|
344
345
|
|
|
345
346
|
/**
|
|
@@ -350,7 +351,6 @@ class PlaySocket {
|
|
|
350
351
|
* @param {*} updateValue - New value for update-matching
|
|
351
352
|
*/
|
|
352
353
|
updateStorageArray(key, operation, value, updateValue) {
|
|
353
|
-
this.#handleArrayUpdate(key, operation, value, updateValue);
|
|
354
354
|
this.#sendToServer({
|
|
355
355
|
type: 'room_storage_array_update',
|
|
356
356
|
key,
|
|
@@ -358,6 +358,8 @@ class PlaySocket {
|
|
|
358
358
|
value,
|
|
359
359
|
updateValue
|
|
360
360
|
});
|
|
361
|
+
// Optimistic update AFTER sendToServer to preserve order if messages are being sent in the event callback
|
|
362
|
+
this.#handleArrayUpdate(key, operation, value, updateValue);
|
|
361
363
|
}
|
|
362
364
|
|
|
363
365
|
/**
|