mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 04:09:29 +02:00
update socket on jackpot
This commit is contained in:
@@ -28,11 +28,14 @@ export function ConnectToChat() {
|
|||||||
eventBus.emit('dataChat', event.data);
|
eventBus.emit('dataChat', event.data);
|
||||||
console.log('CHAT')
|
console.log('CHAT')
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (data.MessageType == "CrashGameState") {
|
||||||
eventBus.emit('crash', event.data)
|
eventBus.emit('crash', event.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('Message from Server:', event.data);
|
if (Array.isArray(data.CurrentGame.PlayerList)) {
|
||||||
|
eventBus.emit('jackpotGameTik', event.data)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
webSocket.onclose = function () {
|
webSocket.onclose = function () {
|
||||||
|
|||||||
@@ -1,59 +1,59 @@
|
|||||||
import { BackendWebSocketJackpotUrl } from '@/properties/Сonfig.js';
|
// import { BackendWebSocketJackpotUrl } from '@/properties/Сonfig.js';
|
||||||
import { BackendApiUrl } from '@/properties/Сonfig.js';
|
import { BackendApiUrl } from '@/properties/Сonfig.js';
|
||||||
import { eventBus } from "@/main";
|
// import { eventBus } from "@/main";
|
||||||
|
|
||||||
// import {
|
// import {
|
||||||
// GetCookie
|
// GetCookie
|
||||||
// } from "@/assets/js/storage/CookieStorage.js";
|
// } from "@/assets/js/storage/CookieStorage.js";
|
||||||
|
|
||||||
let webSocket;
|
// let webSocket;
|
||||||
|
|
||||||
export function ConnectToJackpotSocket() {
|
// export function ConnectToJackpotSocket() {
|
||||||
try {
|
// try {
|
||||||
|
|
||||||
if (webSocket && webSocket.readyState === WebSocket.OPEN) {
|
// if (webSocket && webSocket.readyState === WebSocket.OPEN) {
|
||||||
console.log('WebSocket connection already established.');
|
// console.log('WebSocket connection already established.');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
webSocket = new WebSocket(BackendWebSocketJackpotUrl);
|
// webSocket = new WebSocket(BackendWebSocketJackpotUrl);
|
||||||
|
|
||||||
webSocket.onopen = function () {
|
// webSocket.onopen = function () {
|
||||||
console.log('Connection established');
|
// console.log('Connection established');
|
||||||
};
|
// };
|
||||||
|
|
||||||
webSocket.onmessage = function (event) {
|
// webSocket.onmessage = function (event) {
|
||||||
|
|
||||||
// const dataObject = JSON.parse(event.data);
|
// // const dataObject = JSON.parse(event.data);
|
||||||
|
|
||||||
eventBus.emit('jackpotGameTik', event.data);
|
// eventBus.emit('jackpotGameTik', event.data);
|
||||||
|
|
||||||
// console.log(dataObject)
|
// // console.log(dataObject)
|
||||||
// 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')
|
||||||
// }
|
// // }
|
||||||
// else {
|
// // else {
|
||||||
// eventBus.emit('crash', event.data)
|
// // eventBus.emit('crash', event.data)
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
};
|
// };
|
||||||
|
|
||||||
webSocket.onclose = function () {
|
// webSocket.onclose = function () {
|
||||||
|
|
||||||
webSocket = new WebSocket(BackendWebSocketJackpotUrl);
|
// webSocket = new WebSocket(BackendWebSocketJackpotUrl);
|
||||||
|
|
||||||
console.log('Connection closed and reconnected');
|
// console.log('Connection closed and reconnected');
|
||||||
};
|
// };
|
||||||
|
|
||||||
webSocket.onerror = function (event) {
|
// webSocket.onerror = function (event) {
|
||||||
webSocket = new WebSocket(BackendWebSocketJackpotUrl);
|
// webSocket = new WebSocket(BackendWebSocketJackpotUrl);
|
||||||
console.error('WebSocket Error:', event);
|
// console.error('WebSocket Error:', event);
|
||||||
};
|
// };
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('Error in ConnectToChat:', error);
|
// console.error('Error in ConnectToChat:', error);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
export async function JoinJackpotGame(userData, amount) {
|
export async function JoinJackpotGame(userData, amount) {
|
||||||
const data = {
|
const data = {
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ import "@/assets/css/PagesStyles/games-pages/jackpot.css";
|
|||||||
import "@/assets/css/global.css";
|
import "@/assets/css/global.css";
|
||||||
import JackpotNumbers from "@/mocks/JackpotNumbers";
|
import JackpotNumbers from "@/mocks/JackpotNumbers";
|
||||||
import {
|
import {
|
||||||
ConnectToJackpotSocket,
|
// ConnectToJackpotSocket,
|
||||||
JoinJackpotGame,
|
JoinJackpotGame,
|
||||||
} from "@/assets/js/jackpot/JackpotLogic.js";
|
} from "@/assets/js/jackpot/JackpotLogic.js";
|
||||||
import { useVuelidate } from "@vuelidate/core";
|
import { useVuelidate } from "@vuelidate/core";
|
||||||
@@ -659,7 +659,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
ConnectToJackpotSocket();
|
// ConnectToJackpotSocket();
|
||||||
|
|
||||||
eventBus.on("jackpotGameTik", (data) => {
|
eventBus.on("jackpotGameTik", (data) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user