![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/public_html/public/ |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebSocket & Video Call Debug</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background: #f5f5f5;
}
.container {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
button {
background: #3b82f6;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
button:hover {
background: #2563eb;
}
button:disabled {
background: #9ca3af;
cursor: not-allowed;
}
.status {
margin: 10px 0;
padding: 10px;
border-radius: 5px;
}
.status.connected {
background: #d1fae5;
border: 1px solid #10b981;
color: #047857;
}
.status.disconnected {
background: #fee2e2;
border: 1px solid #ef4444;
color: #dc2626;
}
.log {
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 5px;
padding: 10px;
height: 200px;
overflow-y: auto;
font-family: monospace;
font-size: 12px;
white-space: pre-wrap;
}
input, select {
padding: 8px;
border: 1px solid #d1d5db;
border-radius: 4px;
margin: 5px;
}
</style>
</head>
<body>
<h1>đ§ WebSocket & Video Call Debug Tool</h1>
<div class="container">
<h2>Connection Setup</h2>
<div>
<label>User ID: <input type="text" id="userId" value="debug-user-1" /></label>
<label>User Name: <input type="text" id="userName" value="Debug User 1" /></label>
<label>Protocol:
<select id="protocol">
<option value="auto">Auto (ws/wss)</option>
<option value="ws">WebSocket (ws://)</option>
<option value="wss">Secure WebSocket (wss://)</option>
</select>
</label>
</div>
<div>
<button onclick="connect()">Connect WebSocket</button>
<button onclick="disconnect()">Disconnect</button>
<button onclick="clearLog()">Clear Log</button>
</div>
<div id="connectionStatus" class="status disconnected">Disconnected</div>
</div>
<div class="grid">
<div class="container">
<h3>WebSocket Testing</h3>
<div>
<button onclick="sendPing()" id="pingBtn" disabled>Send Ping</button>
<button onclick="joinRoom()" id="joinBtn" disabled>Join Test Room</button>
<button onclick="sendMessage()" id="msgBtn" disabled>Send Test Message</button>
</div>
<div>
<label>Recipient ID: <input type="text" id="recipientId" value="debug-user-2" /></label>
<button onclick="sendVideoCallOffer()" id="callBtn" disabled>Send Video Call Offer</button>
</div>
<h4>WebSocket Log:</h4>
<div id="wsLog" class="log">Ready to connect...</div>
</div>
<div class="container">
<h3>Video Call Testing</h3>
<div>
<button onclick="testMockStream()" id="mockBtn">Test Mock Video Stream</button>
<button onclick="testRealStream()" id="realBtn">Test Real Camera</button>
<button onclick="stopVideo()" id="stopBtn" disabled>Stop Video</button>
</div>
<video id="testVideo" width="300" height="200" autoplay muted style="background: #000; border-radius: 8px; margin: 10px 0;"></video>
<h4>Video Test Log:</h4>
<div id="videoLog" class="log">Ready to test video...</div>
</div>
</div>
<script>
let ws = null;
let currentStream = null;
const wsLog = document.getElementById('wsLog');
const videoLog = document.getElementById('videoLog');
const connectionStatus = document.getElementById('connectionStatus');
function logWS(message) {
const timestamp = new Date().toLocaleTimeString();
wsLog.textContent += `[${timestamp}] ${message}\n`;
wsLog.scrollTop = wsLog.scrollHeight;
}
function logVideo(message) {
const timestamp = new Date().toLocaleTimeString();
videoLog.textContent += `[${timestamp}] ${message}\n`;
videoLog.scrollTop = videoLog.scrollHeight;
}
function updateConnectionStatus(connected) {
connectionStatus.textContent = connected ? 'Connected â
' : 'Disconnected â';
connectionStatus.className = `status ${connected ? 'connected' : 'disconnected'}`;
// Enable/disable buttons based on connection
document.getElementById('pingBtn').disabled = !connected;
document.getElementById('joinBtn').disabled = !connected;
document.getElementById('msgBtn').disabled = !connected;
document.getElementById('callBtn').disabled = !connected;
}
function connect() {
if (ws && ws.readyState < 2) {
logWS('Already connected or connecting');
return;
}
const userId = document.getElementById('userId').value;
const userName = document.getElementById('userName').value;
const protocolSelect = document.getElementById('protocol').value;
if (!userId || !userName) {
alert('Please enter User ID and Name');
return;
}
const user = JSON.stringify({
id: userId,
name: userName,
email: `${userId}@debug.com`,
role: 'USER'
});
let protocol;
if (protocolSelect === 'auto') {
protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
} else {
protocol = protocolSelect + ':';
}
const wsUrl = `${protocol}//${window.location.host}/_ws?userId=${userId}&user=${encodeURIComponent(user)}&connId=debug_${Date.now()}`;
logWS(`Connecting to: ${wsUrl}`);
ws = new WebSocket(wsUrl);
ws.onopen = function() {
logWS('â
WebSocket connected successfully');
updateConnectionStatus(true);
};
ws.onmessage = function(event) {
const data = JSON.parse(event.data);
logWS(`đĨ Received: ${data.type} - ${JSON.stringify(data.data || {})}`);
// Handle specific message types
if (data.type === 'webrtc-offer') {
logWS('đ INCOMING VIDEO CALL OFFER!');
if (confirm('Accept incoming video call?')) {
// Simulate accepting the call
const response = {
type: 'webrtc-answer',
data: {
recipientId: data.senderId,
signal: { type: 'answer', sdp: 'mock-answer-sdp' }
}
};
ws.send(JSON.stringify(response));
logWS('đ Sent webrtc-answer');
}
}
};
ws.onclose = function(event) {
logWS(`đ WebSocket closed - Code: ${event.code}, Reason: "${event.reason}"`);
updateConnectionStatus(false);
};
ws.onerror = function(error) {
logWS(`â WebSocket error: ${error}`);
updateConnectionStatus(false);
};
}
function disconnect() {
if (ws) {
logWS('Disconnecting...');
ws.close(1000, 'Manual disconnect');
}
}
function sendPing() {
if (ws && ws.readyState === WebSocket.OPEN) {
const message = JSON.stringify({ type: 'ping' });
ws.send(message);
logWS(`đ¤ Sent: ping`);
} else {
logWS('â Cannot send - not connected');
}
}
function joinRoom() {
if (ws && ws.readyState === WebSocket.OPEN) {
const message = JSON.stringify({
type: 'JOIN_ROOM',
data: { chatRoomId: 'debug-room-123' }
});
ws.send(message);
logWS(`đ¤ Sent: JOIN_ROOM`);
} else {
logWS('â Cannot send - not connected');
}
}
function sendMessage() {
if (ws && ws.readyState === WebSocket.OPEN) {
const message = JSON.stringify({
type: 'CHAT_MESSAGE',
data: {
content: 'Debug test message',
chatRoomId: 'debug-room-123'
}
});
ws.send(message);
logWS(`đ¤ Sent: CHAT_MESSAGE`);
} else {
logWS('â Cannot send - not connected');
}
}
function sendVideoCallOffer() {
if (ws && ws.readyState === WebSocket.OPEN) {
const recipientId = document.getElementById('recipientId').value;
if (!recipientId) {
alert('Please enter Recipient ID');
return;
}
const message = JSON.stringify({
type: 'webrtc-offer',
data: {
recipientId: recipientId,
signal: {
type: 'offer',
sdp: 'mock-offer-sdp-for-testing'
}
}
});
ws.send(message);
logWS(`đ¤ Sent: webrtc-offer to ${recipientId}`);
} else {
logWS('â Cannot send - not connected');
}
}
function createMockVideoStream() {
const canvas = document.createElement('canvas');
canvas.width = 640;
canvas.height = 480;
const ctx = canvas.getContext('2d');
let frame = 0;
const animate = () => {
if (ctx && currentStream) {
// Clear canvas
ctx.fillStyle = '#1f2937';
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Draw animated circle
const x = canvas.width / 2 + Math.sin(frame * 0.05) * 100;
const y = canvas.height / 2 + Math.cos(frame * 0.03) * 50;
ctx.fillStyle = '#3b82f6';
ctx.beginPath();
ctx.arc(x, y, 30, 0, 2 * Math.PI);
ctx.fill();
// Draw text
ctx.fillStyle = '#ffffff';
ctx.font = '20px Arial';
ctx.textAlign = 'center';
ctx.fillText('DEBUG MOCK VIDEO', canvas.width / 2, canvas.height / 2 + 100);
ctx.fillText(`Frame: ${frame}`, canvas.width / 2, canvas.height / 2 + 130);
frame++;
requestAnimationFrame(animate);
}
};
const stream = canvas.captureStream(30);
animate();
return stream;
}
function testMockStream() {
stopVideo();
logVideo('đ Creating mock video stream...');
try {
currentStream = createMockVideoStream();
document.getElementById('testVideo').srcObject = currentStream;
logVideo('â
Mock stream active');
document.getElementById('stopBtn').disabled = false;
} catch (err) {
logVideo('â Failed to create mock stream: ' + err.message);
}
}
async function testRealStream() {
stopVideo();
logVideo('đš Attempting to access real camera...');
try {
currentStream = await navigator.mediaDevices.getUserMedia({
video: { width: { ideal: 640 }, height: { ideal: 480 } },
audio: true
});
document.getElementById('testVideo').srcObject = currentStream;
logVideo('â
Real camera stream active');
document.getElementById('stopBtn').disabled = false;
} catch (err) {
logVideo('â ī¸ Real camera failed, trying mock stream...');
testMockStream();
}
}
function stopVideo() {
if (currentStream) {
currentStream.getTracks().forEach(track => track.stop());
currentStream = null;
document.getElementById('testVideo').srcObject = null;
logVideo('âšī¸ Video stream stopped');
document.getElementById('stopBtn').disabled = true;
}
}
function clearLog() {
wsLog.textContent = 'Log cleared...\n';
videoLog.textContent = 'Log cleared...\n';
}
// Auto-connect on page load
window.addEventListener('load', () => {
logWS('Debug tool loaded. Click Connect to start.');
logVideo('Video test ready. Try mock or real stream.');
});
// Clean up on page unload
window.addEventListener('beforeunload', () => {
stopVideo();
if (ws) ws.close();
});
</script>
</body>
</html>