mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 04:09:29 +02:00
fix socket on crash
This commit is contained in:
@@ -10,7 +10,6 @@ export function ConnectToChat() {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
if (webSocket && webSocket.readyState === WebSocket.OPEN) {
|
if (webSocket && webSocket.readyState === WebSocket.OPEN) {
|
||||||
console.log('WebSocket connection already established.');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,19 +21,24 @@ export function ConnectToChat() {
|
|||||||
|
|
||||||
webSocket.onmessage = function (event) {
|
webSocket.onmessage = function (event) {
|
||||||
|
|
||||||
const dataObject = JSON.parse(event.data);
|
try {
|
||||||
|
const dataObject = JSON.parse(event.data);
|
||||||
|
|
||||||
if (dataObject && Object.prototype.hasOwnProperty.call(dataObject, 'SpUserName') && Object.prototype.hasOwnProperty.call(dataObject, 'Message')) {
|
if (dataObject && Object.prototype.hasOwnProperty.call(dataObject, 'SpUserName') && Object.prototype.hasOwnProperty.call(dataObject, 'Message')) {
|
||||||
eventBus.emit('dataChat', event.data);
|
eventBus.emit('dataChat', event.data);
|
||||||
console.log('CHAT')
|
console.log('CHAT')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.MessageType == "CrashGameState") {
|
if (dataObject.MessageType == "CrashGameState") {
|
||||||
eventBus.emit('crash', event.data)
|
eventBus.emit('crash', event.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(dataObject.CurrentGame.PlayerList)) {
|
||||||
|
eventBus.emit('jackpotGameTik', event.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
if (Array.isArray(data.CurrentGame.PlayerList)) {
|
|
||||||
eventBus.emit('jackpotGameTik', event.data)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user