feat/reverb (#20)
Co-authored-by: jon brookes <marshyon@gmail.com> Reviewed-on: https://codeberg.org/headshed/share-lt/pulls/20
This commit is contained in:
parent
74bc17d019
commit
21147af908
30 changed files with 1948 additions and 29 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
document.addEventListener('livewire:init', () => {
|
||||
Livewire.on('insert-editor-content', (data) => {
|
||||
// console.log('Received insert-editor-content data:', data);
|
||||
|
|
@ -44,3 +43,11 @@ document.addEventListener('livewire:init', () => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Echo exposes an expressive API for subscribing to channels and listening
|
||||
* for events that are broadcast by Laravel. Echo and event broadcasting
|
||||
* allow your team to quickly build robust real-time web applications.
|
||||
*/
|
||||
|
||||
import './echo';
|
||||
|
|
|
|||
28
resources/js/echo.js
Normal file
28
resources/js/echo.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import Echo from 'laravel-echo';
|
||||
import Pusher from 'pusher-js';
|
||||
|
||||
window.Pusher = Pusher;
|
||||
|
||||
// Add error handling and logging
|
||||
try {
|
||||
console.log('Initializing Echo with:', {
|
||||
key: import.meta.env.VITE_REVERB_APP_KEY,
|
||||
wsHost: import.meta.env.VITE_REVERB_HOST,
|
||||
wsPort: import.meta.env.VITE_REVERB_PORT,
|
||||
scheme: import.meta.env.VITE_REVERB_SCHEME
|
||||
});
|
||||
|
||||
window.Echo = new Echo({
|
||||
broadcaster: 'reverb',
|
||||
key: import.meta.env.VITE_REVERB_APP_KEY,
|
||||
wsHost: import.meta.env.VITE_REVERB_HOST,
|
||||
wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
|
||||
wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
|
||||
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
|
||||
enabledTransports: ['ws', 'wss'],
|
||||
});
|
||||
|
||||
console.log('Echo initialized:', window.Echo);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize Echo:', error);
|
||||
}
|
||||
50
resources/views/test-reverb.blade.php
Normal file
50
resources/views/test-reverb.blade.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Reverb Test</title>
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Reverb Connection Test</h1>
|
||||
<div id="status">Waiting for Echo...</div>
|
||||
<div id="messages"></div>
|
||||
|
||||
<script>
|
||||
const status = document.getElementById('status');
|
||||
const messages = document.getElementById('messages');
|
||||
|
||||
// Wait for Echo to be ready
|
||||
function checkEcho() {
|
||||
console.log('Checking Echo:', window.Echo);
|
||||
|
||||
if (window.Echo && window.Echo !== null) {
|
||||
status.textContent = 'Echo ready, connecting...';
|
||||
status.style.color = 'blue';
|
||||
|
||||
try {
|
||||
window.Echo.channel('test-channel')
|
||||
.listen('test.message', (e) => {
|
||||
console.log('Received message:', e);
|
||||
messages.innerHTML += `<p>Received: ${e.message}</p>`;
|
||||
});
|
||||
|
||||
status.textContent = 'Connected to Reverb!';
|
||||
status.style.color = 'green';
|
||||
} catch (error) {
|
||||
status.textContent = `Connection failed: ${error.message}`;
|
||||
status.style.color = 'red';
|
||||
console.error('Echo error:', error);
|
||||
}
|
||||
} else {
|
||||
setTimeout(checkEcho, 100); // Check again in 100ms
|
||||
}
|
||||
}
|
||||
|
||||
// Start checking after DOM loads
|
||||
document.addEventListener('DOMContentLoaded', checkEcho);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue