fix socket on crash

This commit is contained in:
Hepatica
2024-03-05 22:10:06 +01:00
parent 82db553ca9
commit 8b8c907730

View File

@@ -10,7 +10,6 @@ export function ConnectToChat() {
try {
if (webSocket && webSocket.readyState === WebSocket.OPEN) {
console.log('WebSocket connection already established.');
return;
}
@@ -22,6 +21,7 @@ export function ConnectToChat() {
webSocket.onmessage = function (event) {
try {
const dataObject = JSON.parse(event.data);
if (dataObject && Object.prototype.hasOwnProperty.call(dataObject, 'SpUserName') && Object.prototype.hasOwnProperty.call(dataObject, 'Message')) {
@@ -29,13 +29,17 @@ export function ConnectToChat() {
console.log('CHAT')
}
if (data.MessageType == "CrashGameState") {
if (dataObject.MessageType == "CrashGameState") {
eventBus.emit('crash', event.data)
}
if (Array.isArray(data.CurrentGame.PlayerList)) {
if (Array.isArray(dataObject.CurrentGame.PlayerList)) {
eventBus.emit('jackpotGameTik', event.data)
}
} catch (error) {
}
};
webSocket.onclose = function () {