[mirotalksfu] - improve webhook, add readme

هذا الالتزام موجود في:
Miroslav Pejic
2025-01-16 16:02:14 +01:00
الأصل 9ce98c98ac
التزام 0cf6fda6d1
8 ملفات معدلة مع 71 إضافات و15 حذوفات

50
webhook/README.md Normal file
عرض الملف

@@ -0,0 +1,50 @@
# Webhooks Example
![webhook](./webhooks.png)
This example shows how to set up a server to listen for MiroTalk SFU webhook events (join, exitRoom, disconnect).
### Step 1: Enable Webhooks
Edit `app/src/config.js` to enable webhooks:
```javascript
webhook: {
enabled: true, // Enable webhook functionality
url: 'http://localhost:8888/webhook-endpoint', // Webhook server URL
},
```
---
### Step 2: Run the Webhook Server
1. **Install dependencies**:
```bash
npm install
```
2. **Start the server**:
```bash
npm start
```
---
### Step 3: Webhook Events
MiroTalk SFU sends HTTP `POST` requests to the specified URL with event data:
**Example Payload**:
```json
{
"event": "join",
"data": {}
}
```
- **Events**: `join`, `exit`, `disconnect`.
- **Data**: Includes `event` and custom `data`.

عرض الملف

@@ -15,10 +15,6 @@ app.post('/webhook-endpoint', (req, res) => {
// Handle different events
switch (event) {
case 'disconnect':
console.log('User disconnected:', data);
// Add your custom logic here
break;
case 'join':
console.log('User joined:', data);
// Add your custom logic here
@@ -27,6 +23,10 @@ app.post('/webhook-endpoint', (req, res) => {
console.log('User exited:', data);
// Add your custom logic here
break;
case 'disconnect':
console.log('User disconnected:', data);
// Add your custom logic here
break;
default:
console.error('Unknown event type');
break;

ثنائية
webhook/webhooks.png Normal file

ملف ثنائي غير معروض.

بعد

العرض:  |  الارتفاع:  |  الحجم: 5.4 KiB