|
|
|
@ -3,6 +3,7 @@ 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
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
function fetchClientData() {
|
|
|
|
|
return fetch('https://osina.ositcom.com/get-client-ip/')
|
|
|
|
|
.then(response => response.json())
|
|
|
|
@ -22,7 +23,6 @@ function fetchClientData() {
|
|
|
|
|
function initializeWebSocket() {
|
|
|
|
|
const referrer = document.referrer;
|
|
|
|
|
|
|
|
|
|
// Fetch client data and then initialize WebSocket
|
|
|
|
|
fetchClientData().then(({ client_ip, client_country }) => {
|
|
|
|
|
const visitorsSocket = new WebSocket(visitorsSocketUrl);
|
|
|
|
|
|
|
|
|
@ -50,3 +50,4 @@ function initializeWebSocket() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initializeWebSocket();
|
|
|
|
|
});
|
|
|
|
|