diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc
index 0c55c43..5f0037b 100644
Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ
diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc
index 51dcfcb..5fbdbe9 100644
Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ
diff --git a/core/templates/core/chat.html b/core/templates/core/chat.html
index 872adbe..7126ade 100644
--- a/core/templates/core/chat.html
+++ b/core/templates/core/chat.html
@@ -166,6 +166,7 @@
+
Connecting...
@@ -175,6 +176,14 @@
+
+
+
+
@@ -208,8 +217,17 @@
// Sanitize username for PeerJS ID (only alphanumeric, -, _)
const sanitizeId = (id) => id.replace(/[^a-zA-Z0-9-_]/g, '_');
- // Initialize PeerJS
+ // Initialize PeerJS with STUN servers for reliability
let peer = new Peer(PEER_ID_PREFIX + sanitizeId(MY_USERNAME), {
+ config: {
+ 'iceServers': [
+ { url: 'stun:stun.l.google.com:19302' },
+ { url: 'stun:stun1.l.google.com:19302' },
+ { url: 'stun:stun2.l.google.com:19302' },
+ { url: 'stun:stun3.l.google.com:19302' },
+ { url: 'stun:stun4.l.google.com:19302' },
+ ]
+ },
debug: 1
});
@@ -221,7 +239,22 @@
const localVideo = document.getElementById('localVideo');
const remoteVideo = document.getElementById('remoteVideo');
const remoteVideoWrapper = document.getElementById('remoteVideoWrapper');
+ const callStatus = document.getElementById('callStatus');
+ const incomingRing = document.getElementById('incomingRing');
+ const outgoingRing = document.getElementById('outgoingRing');
+ function playRingtone(type) {
+ if (type === 'incoming') incomingRing.play().catch(e => console.log('Audio blocked'));
+ if (type === 'outgoing') outgoingRing.play().catch(e => console.log('Audio blocked'));
+ }
+
+ function stopRingtones() {
+ incomingRing.pause();
+ incomingRing.currentTime = 0;
+ outgoingRing.pause();
+ outgoingRing.currentTime = 0;
+ }
+
// Handle Peer Open
peer.on('open', (id) => {
console.log('My peer ID is: ' + id);
@@ -230,15 +263,16 @@
// Handle incoming calls
peer.on('call', (call) => {
console.log('Incoming call from: ' + call.peer);
- // Only accept if it's the other user we are chatting with
if (call.peer === PEER_ID_PREFIX + sanitizeId(OTHER_USERNAME)) {
+ // If already in a call, busy logic could go here
currentCall = call;
incomingCallUI.style.display = 'block';
+ playRingtone('incoming');
- // Auto-hide incoming call after 30 seconds if not answered
setTimeout(() => {
if (incomingCallUI.style.display === 'block') {
incomingCallUI.style.display = 'none';
+ stopRingtones();
}
}, 30000);
}
@@ -247,6 +281,7 @@
// Start Call Function
async function startCall(videoEnabled = true) {
try {
+ callStatus.innerText = "Requesting permissions...";
localStream = await navigator.mediaDevices.getUserMedia({
video: videoEnabled,
audio: true
@@ -254,12 +289,14 @@
localVideo.srcObject = localStream;
callModal.show();
+ callStatus.innerText = "Calling...";
+ playRingtone('outgoing');
const call = peer.call(PEER_ID_PREFIX + sanitizeId(OTHER_USERNAME), localStream);
handleCall(call);
} catch (err) {
console.error('Failed to get local stream', err);
- alert('Could not access camera or microphone. Please ensure you have given permission.');
+ alert('Could not access camera or microphone.');
}
}
@@ -267,6 +304,8 @@
currentCall = call;
call.on('stream', (remoteStream) => {
console.log('Received remote stream');
+ stopRingtones();
+ callStatus.innerText = "Connected";
remoteVideo.srcObject = remoteStream;
remoteVideoWrapper.style.display = 'block';
});
@@ -275,6 +314,7 @@
});
call.on('error', (err) => {
console.error('Call error:', err);
+ stopRingtones();
endCall();
});
}
@@ -285,7 +325,9 @@
document.getElementById('acceptCall').addEventListener('click', async () => {
incomingCallUI.style.display = 'none';
+ stopRingtones();
try {
+ callStatus.innerText = "Answering...";
localStream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: true
@@ -303,6 +345,7 @@
document.getElementById('rejectCall').addEventListener('click', () => {
incomingCallUI.style.display = 'none';
+ stopRingtones();
if (currentCall) currentCall.close();
});
@@ -311,6 +354,7 @@
});
function endCall() {
+ stopRingtones();
if (currentCall) currentCall.close();
if (localStream) {
localStream.getTracks().forEach(track => track.stop());
diff --git a/core/templates/core/welcome.html b/core/templates/core/welcome.html
new file mode 100644
index 0000000..4153d37
--- /dev/null
+++ b/core/templates/core/welcome.html
@@ -0,0 +1,281 @@
+{% extends "base.html" %}
+{% load static %}
+
+{% block title %}Welcome to RaktaPulse{% endblock %}
+
+{% block extra_css %}
+
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+
+
+
+
Save Lives with RaktaPulse
+
Every drop counts. Connect with donors, find blood banks, and request life-saving help in seconds. Join our mission to make blood donation accessible to everyone.