You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the problem is :- when the client try to connect to the server with wrong stream_key is obs access to server and share 2 frames or 3 then ==> session.reject() work.
i fixed this issue by creating a list with stream_keys and compare the obs stream_key with the database stream_key my code :-
File Name:- media_server.js
const NodeMediaServer = require('node-media-server'),
config = require('./config/default').rtmp_server,
User = require('./database/Schema').User;
var keys = [];
User.find({} , (err , result)=>{
result.forEach((key)=>{
keys.push(key.stream_key);
});
});
nms = new NodeMediaServer(config);
nms.on('prePublish', async (id, StreamPath, args) => {
let stream_key = getStreamKeyFromStreamPath(StreamPath);
let count;
for(let i = 0 ; i<=keys.length; ++i){
if(stream_key === keys[i]){
count = 1;
break;
}else{
count = 0;
}
}
if(count != 1){
let session = nms.getSession(id);
session.reject();
}
});
const getStreamKeyFromStreamPath = (path) => {
let parts = path.split('/');
return parts[parts.length - 1];
};
module.exports = nms;
the final result when the client enter a wrong stream_key obs is going to send alert and client never going to send any frame to the server side
*note using forEach will case a bad performance...
The text was updated successfully, but these errors were encountered:
the problem is :- when the client try to connect to the server with wrong stream_key is obs access to server and share 2 frames or 3 then ==> session.reject() work.
i fixed this issue by creating a list with stream_keys and compare the obs stream_key with the database stream_key my code :-
File Name:- media_server.js
the final result when the client enter a wrong stream_key obs is going to send alert and client never going to send any frame to the server side
*note using forEach will case a bad performance...
The text was updated successfully, but these errors were encountered: