mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 04:09:29 +02:00
added v-for for all template in develop-component
This commit is contained in:
@@ -1,66 +1,66 @@
|
||||
import { BackendWebSocketUrl } from '@/properties/Сonfig.js';
|
||||
import { eventBus } from "@/main";
|
||||
import {
|
||||
GetCookie
|
||||
} from "@/assets/js/storage/CookieStorage.js";
|
||||
|
||||
let webSocket;
|
||||
|
||||
export function ConnectToChat() {
|
||||
try {
|
||||
webSocket = new WebSocket(BackendWebSocketUrl);
|
||||
|
||||
webSocket.onopen = function () {
|
||||
console.log('Connection established');
|
||||
};
|
||||
|
||||
webSocket.onmessage = function (event) {
|
||||
|
||||
const dataObject = JSON.parse(event.data);
|
||||
|
||||
if (dataObject && Object.prototype.hasOwnProperty.call(dataObject, 'SpUserName') && Object.prototype.hasOwnProperty.call(dataObject, 'Message')) {
|
||||
eventBus.emit('dataChat', event.data);
|
||||
}
|
||||
|
||||
console.log('Message from Server:', event.data);
|
||||
};
|
||||
|
||||
webSocket.onclose = function () {
|
||||
|
||||
webSocket = new WebSocket(BackendWebSocketUrl);
|
||||
|
||||
console.log('Connection closed and reconnected');
|
||||
};
|
||||
|
||||
webSocket.onerror = function (event) {
|
||||
console.error('WebSocket Error:', event);
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error in ConnectToChat:', error);
|
||||
}
|
||||
}
|
||||
|
||||
export function SendMessageToChat(message) {
|
||||
try {
|
||||
|
||||
if (!GetCookie("SpUserName") && !GetCookie("AUTHTOKEN") && !GetCookie("SearchToken")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const userCredentials = {
|
||||
SearchToken: GetCookie("SearchToken"),
|
||||
AUTHTOKEN: GetCookie("AUTHTOKEN")
|
||||
};
|
||||
|
||||
const messageObject = {
|
||||
UserCredentials: userCredentials,
|
||||
Message: message,
|
||||
MessageType: "Chat"
|
||||
};
|
||||
|
||||
webSocket.send(JSON.stringify(messageObject));
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error in ConnectToChat:', error);
|
||||
}
|
||||
}
|
||||
// import { BackendWebSocketUrl } from '@/properties/Сonfig.js';
|
||||
// import { eventBus } from "@/main";
|
||||
// import {
|
||||
// GetCookie
|
||||
// } from "@/assets/js/storage/CookieStorage.js";
|
||||
//
|
||||
// let webSocket;
|
||||
//
|
||||
// export function ConnectToChat() {
|
||||
// try {
|
||||
// webSocket = new WebSocket(BackendWebSocketUrl);
|
||||
//
|
||||
// webSocket.onopen = function () {
|
||||
// console.log('Connection established');
|
||||
// };
|
||||
//
|
||||
// webSocket.onmessage = function (event) {
|
||||
//
|
||||
// const dataObject = JSON.parse(event.data);
|
||||
//
|
||||
// if (dataObject && Object.prototype.hasOwnProperty.call(dataObject, 'SpUserName') && Object.prototype.hasOwnProperty.call(dataObject, 'Message')) {
|
||||
// eventBus.emit('dataChat', event.data);
|
||||
// }
|
||||
//
|
||||
// console.log('Message from Server:', event.data);
|
||||
// };
|
||||
//
|
||||
// webSocket.onclose = function () {
|
||||
//
|
||||
// webSocket = new WebSocket(BackendWebSocketUrl);
|
||||
//
|
||||
// console.log('Connection closed and reconnected');
|
||||
// };
|
||||
//
|
||||
// webSocket.onerror = function (event) {
|
||||
// console.error('WebSocket Error:', event);
|
||||
// };
|
||||
// } catch (error) {
|
||||
// console.error('Error in ConnectToChat:', error);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// export function SendMessageToChat(message) {
|
||||
// try {
|
||||
//
|
||||
// if (!GetCookie("SpUserName") && !GetCookie("AUTHTOKEN") && !GetCookie("SearchToken")) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const userCredentials = {
|
||||
// SearchToken: GetCookie("SearchToken"),
|
||||
// AUTHTOKEN: GetCookie("AUTHTOKEN")
|
||||
// };
|
||||
//
|
||||
// const messageObject = {
|
||||
// UserCredentials: userCredentials,
|
||||
// Message: message,
|
||||
// MessageType: "Chat"
|
||||
// };
|
||||
//
|
||||
// webSocket.send(JSON.stringify(messageObject));
|
||||
//
|
||||
// } catch (error) {
|
||||
// console.error('Error in ConnectToChat:', error);
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user