emile 10 months ago
parent 1cc3dc2c4a
commit ef7d33caa4

@ -3,7 +3,8 @@ const my_domain = "osina.ositcom.com";
const visitorsSocketUrl = `${visitors_ws_scheme}://${my_domain}/ws/osichat/visitors/`;
// Function to fetch client IP and country from the API
function fetchClientData() {
document.addEventListener('DOMContentLoaded', () => {
function fetchClientData() {
return fetch('https://osina.ositcom.com/get-client-ip/')
.then(response => response.json())
.then(data => ({
@ -17,12 +18,11 @@ function fetchClientData() {
client_country: 'Unknown'
};
});
}
}
function initializeWebSocket() {
function initializeWebSocket() {
const referrer = document.referrer;
// Fetch client data and then initialize WebSocket
fetchClientData().then(({ client_ip, client_country }) => {
const visitorsSocket = new WebSocket(visitorsSocketUrl);
@ -47,6 +47,7 @@ function initializeWebSocket() {
console.error('WebSocket error:', error);
};
});
}
}
initializeWebSocket();
initializeWebSocket();
});

Loading…
Cancel
Save