emile 10 months ago
parent 199946bee8
commit d1cdfb5d56

Binary file not shown.

@ -5,28 +5,12 @@ from django.template.loader import render_to_string
from asgiref.sync import async_to_sync
from django.shortcuts import get_object_or_404
import requests
from django.contrib.sessions.models import Session
class OsitcomVisitor(WebsocketConsumer):
def connect(self):
cookie_header = dict(self.scope.get('headers', {})).get(b'cookie', b'').decode('utf-8')
self.session_id = None
if cookie_header:
for cookie in cookie_header.split('; '):
key, value = cookie.split('=', 1)
if key == 'sessionid':
self.session_id = value
break
if not self.session_id:
self.session_id = self.scope.get('session', {}).get('_session_key')
if not self.session_id:
# Handle missing session_id scenario, maybe reject the connection
self.close()
return
session = self.scope["session"]
self.session_id = session.session_key
async_to_sync(self.channel_layer.group_add)(
'ositcom_visitors', self.channel_name
)

@ -1,6 +1,6 @@
const chat_ws_scheme = window.location.protocol === "https:" ? "wss" : "ws";
const domain = "192.168.1.111:8000";
const domain = "192.168.1.106:8000";
const osichatSocketUrl = `${chat_ws_scheme}://${domain}/ws/osichat/`;
const osichatSocket = new WebSocket(osichatSocketUrl);

Loading…
Cancel
Save