[mirotalksfu] - improve webhook, add readme
هذا الالتزام موجود في:
@@ -63,10 +63,12 @@ module.exports = class Logger {
|
||||
);
|
||||
}
|
||||
|
||||
getDateTime() {
|
||||
const currentTime = new Date().toLocaleString('en-US', this.tzOptions);
|
||||
const milliseconds = String(new Date().getMilliseconds()).padStart(3, '0');
|
||||
return colors.cyan(`${currentTime}:${milliseconds}`);
|
||||
getDateTime(color = true) {
|
||||
const now = new Date();
|
||||
const currentTime = now.toLocaleString('en-US', this.tzOptions);
|
||||
const milliseconds = String(now.getMilliseconds()).padStart(3, '0');
|
||||
const timestamp = `${currentTime}:${milliseconds}`;
|
||||
return color ? colors.cyan(timestamp) : timestamp;
|
||||
}
|
||||
|
||||
getFormatTime(ms) {
|
||||
|
||||
@@ -55,7 +55,7 @@ dev dependencies: {
|
||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.7.04
|
||||
* @version 1.7.05
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -2843,6 +2843,8 @@ function startServer() {
|
||||
|
||||
if (webhook.enabled) {
|
||||
const data = {
|
||||
timestamp: log.getDateTime(false),
|
||||
room_id: socket.room_id,
|
||||
peer_name: peer_name,
|
||||
presenter: isPresenter,
|
||||
reason: reason,
|
||||
@@ -2895,12 +2897,12 @@ function startServer() {
|
||||
log.info('[REMOVE ME] - Last peer - current active RTMP streams', activeStreams);
|
||||
}
|
||||
|
||||
socket.room_id = null;
|
||||
|
||||
if (isPresenter) removeIP(socket);
|
||||
|
||||
if (webhook.enabled) {
|
||||
const data = {
|
||||
timestamp: log.getDateTime(false),
|
||||
room_id: socket.room_id,
|
||||
peer_name: peer_name,
|
||||
presenter: isPresenter,
|
||||
};
|
||||
@@ -2911,6 +2913,8 @@ function startServer() {
|
||||
.catch((error) => log.error('Error tracking exitRoom event:', error.message));
|
||||
}
|
||||
|
||||
socket.room_id = null;
|
||||
|
||||
callback('Successfully exited room');
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mirotalksfu",
|
||||
"version": "1.7.04",
|
||||
"version": "1.7.05",
|
||||
"description": "WebRTC SFU browser-based video calls",
|
||||
"main": "Server.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
|
||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.7.04
|
||||
* @version 1.7.05
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -4904,7 +4904,7 @@ function showAbout() {
|
||||
imageUrl: image.about,
|
||||
customClass: { image: 'img-about' },
|
||||
position: 'center',
|
||||
title: 'WebRTC SFU v1.7.04',
|
||||
title: 'WebRTC SFU v1.7.05',
|
||||
html: `
|
||||
<br />
|
||||
<div id="about">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.7.04
|
||||
* @version 1.7.05
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
50
webhook/README.md
Normal file
50
webhook/README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Webhooks Example
|
||||
|
||||

|
||||
|
||||
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
ثنائية
webhook/webhooks.png
Normal file
ملف ثنائي غير معروض.
|
بعد العرض: | الارتفاع: | الحجم: 5.4 KiB |
المرجع في مشكلة جديدة
حظر مستخدم