emile 9 months ago
parent d0d967df4b
commit f687b46777

Binary file not shown.

@ -83,6 +83,7 @@ class OsitcomChatRoom(WebsocketConsumer):
mobile_number= text_data_json.get('guest_mobile_number'), mobile_number= text_data_json.get('guest_mobile_number'),
session_id=self.session_id session_id=self.session_id
) )
self.chat_room = chat_room
event = { event = {
'type': 'start_conversation_handler', 'type': 'start_conversation_handler',
'chat_room_id': chat_room.id 'chat_room_id': chat_room.id

@ -1,5 +1,5 @@
const admin_chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws"; const admin_chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
const admin_chat_domain = "192.168.1.111:8000"; const admin_chat_domain = "192.168.1.106:8000";
let chatWebSocket = null; let chatWebSocket = null;
function openConversation(chatId) { function openConversation(chatId) {

@ -1,12 +1,10 @@
const chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws"; const chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
const domain = "192.168.1.111:8000"; const domain = "192.168.1.106:8000";
// Function to fetch session ID // Function to fetch session ID
async function fetchSessionID() { async function fetchSessionID() {
try { try {
const response = await fetch('http://192.168.1.111:3000/get-client-session/'); const response = await fetch('http://192.168.1.106:3000/get-client-session/');
const data = await response.json(); const data = await response.json();
return data.session_id; return data.session_id;
} catch (error) { } catch (error) {
@ -90,9 +88,30 @@ async function initializeChatWebSocket() {
} }
} else if (data.event_type === 'start_conversation') { } else if (data.event_type === 'start_conversation') {
const chatDiv = document.getElementById('startChatContainer'); const chatDiv = document.getElementById('osichat');
const html = data.html; const html = data.html;
chatDiv.innerHTML = html; chatDiv.innerHTML = html;
const textareaScript = document.createElement('script');
textareaScript.type = 'text/javascript';
textareaScript.src = `http://${domain}/static/js/osichat/textarea.js`;
chatDiv.appendChild(textareaScript);
const sendMessageContainer = document.getElementById('sendMessage');
sendMessageContainer.addEventListener('submit', function (event) {
event.preventDefault();
const message = event.target.elements.message.value;
const eventMessage = {
'event_type': 'send_message',
'message': message,
};
osichatSocket.send(JSON.stringify(eventMessage));
event.target.reset();
});
} else if (data.event_type === 'send_message') { } else if (data.event_type === 'send_message') {
const messagesDiv = document.getElementById('messages'); const messagesDiv = document.getElementById('messages');

@ -1,9 +1,9 @@
const visitors_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws"; const visitors_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
const my_domain = "192.168.1.111:8000"; const my_domain = "192.168.1.106:8000";
async function fetchClientData() { async function fetchClientData() {
try { try {
const response = await fetch('http://192.168.1.111:8000/get-client-ip/'); const response = await fetch('http://192.168.1.106:8000/get-client-ip/');
const data = await response.json(); const data = await response.json();
return { return {
client_ip: data.ip, client_ip: data.ip,
@ -20,7 +20,7 @@ async function fetchClientData() {
async function fetchVisitorsSession() { async function fetchVisitorsSession() {
try { try {
const response = await fetch('http://192.168.1.111:3000/get-client-session/'); const response = await fetch('http://192.168.1.106:3000/get-client-session/');
const data = await response.json(); const data = await response.json();
return data.session_id; return data.session_id;
} catch (error) { } catch (error) {
@ -30,7 +30,6 @@ async function fetchVisitorsSession() {
} }
async function initializeVisitorsWebSocket() { async function initializeVisitorsWebSocket() {
console.log('Initializing WebSocket...');
const referrer = document.referrer; const referrer = document.referrer;
const clientData = await fetchClientData(); const clientData = await fetchClientData();

Loading…
Cancel
Save