|
|
|
@ -1,32 +1,40 @@
|
|
|
|
|
const visitors_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
|
|
|
|
|
const my_domain = "192.168.1.106:8000";
|
|
|
|
|
const my_domain = "osina.ositcom.com";
|
|
|
|
|
|
|
|
|
|
async function fetchClientData() {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch('http://192.168.1.106:8000/get-client-ip/');
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
return {
|
|
|
|
|
client_ip: data.ip,
|
|
|
|
|
client_country: data.country
|
|
|
|
|
};
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching client data:', error);
|
|
|
|
|
return {
|
|
|
|
|
client_ip: 'Unknown',
|
|
|
|
|
client_country: 'Unknown'
|
|
|
|
|
};
|
|
|
|
|
let clientData = { client_ip: 'Unknown', client_country: 'Unknown' };
|
|
|
|
|
while (clientData.client_ip === 'Unknown') {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch('https://ositcom.com/get-client-ip/');
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
if (data.ip) {
|
|
|
|
|
clientData = {
|
|
|
|
|
client_ip: data.ip,
|
|
|
|
|
client_country: data.country || 'Unknown'
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching client data:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return clientData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function fetchVisitorsSession() {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch('http://192.168.1.106:3000/get-client-session/');
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
return data.session_id;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching session ID:', error);
|
|
|
|
|
return 'Unknown';
|
|
|
|
|
let session_id = 'Unknown';
|
|
|
|
|
while (session_id === 'Unknown') {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch('http://192.168.1.111:3000/get-client-session/');
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
if (data.session_id) {
|
|
|
|
|
session_id = data.session_id;
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching session ID:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return session_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function initializeVisitorsWebSocket() {
|
|
|
|
|