Get notified when someone joins your rooms
&poke=YOUR_TOPIC to your VDO.Ninja room URL.For easier setup, use the "Create from VDO.Ninja URL" option below. It will automatically generate a topic based on your room settings and give you a ready-to-use link.
Enter your VDO.Ninja URL to automatically create a notification topic
Click a button below to test the notification system.
No notifications yet.
Learn how to integrate with the VDO.Ninja notification system using Server-Sent Events (SSE).
This API allows developers to subscribe to room join events programmatically using SSE.
// Basic SSE connection
const topic = "your_notification_topic";
const evtSource = new EventSource(\`https://notify.vdo.ninja/events?topic=\${topic}\`);
// Handle connection
evtSource.addEventListener('connect', (event) => {
console.log('Connected to notification service', JSON.parse(event.data));
});
// Listen for notifications
evtSource.addEventListener('notification', (event) => {
const notification = JSON.parse(event.data);
console.log('New notification received:', notification);
// Handle notification - show alert, update UI, etc.
});
// Handle errors and reconnection
evtSource.onerror = (error) => {
console.error('SSE connection error:', error);
// Implement reconnection logic here
if (evtSource.readyState === EventSource.CLOSED) {
// Connection closed, try to reconnect
setTimeout(() => {
// Reconnect logic
}, 2000);
}
};
// To disconnect
function disconnect() {
if (evtSource) {
evtSource.close();
evtSource = null;
}
}
For browsers that don't support SSE or in cases where long-lived connections are problematic:
// Polling fallback example
async function pollForNotifications(topic, lastPollTime) {
try {
const response = await fetch(
\`https://notify.vdo.ninja/poll?topic=\${topic}&since=\${lastPollTime}\`
);
const data = await response.json();
if (data.error) {
console.error('Error during polling:', data.error);
} else if (data.notifications && data.notifications.length > 0) {
data.notifications.forEach(notification => {
console.log('New notification:', notification);
// Handle notification
});
}
return Date.now(); // Return current time for next poll
} catch (error) {
console.error('Error during fallback polling:', error);
return lastPollTime; // Keep the same lastPollTime on error
}
}
// Start polling every minute
let lastPollTime = Date.now();
const pollingInterval = setInterval(async () => {
lastPollTime = await pollForNotifications('your_topic', lastPollTime);
}, 60000);
| Endpoint | Description |
|---|---|
/events?topic={topic} |
SSE endpoint for real-time notifications |
/poll?topic={topic}&since={timestamp} |
Polling endpoint for fetching notifications since a timestamp |
/?notify={topic}&message={message} |
Send a notification to a topic |
For a complete integration example, check out the NotificationManager class in the source code of this page.