mirror of
https://gitlab.com/Shinobi-Systems/ShinobiCE.git
synced 2025-03-09 15:40:15 +00:00
Son Goku
- Rebased sql, test, web, defintions, languages, INSTALL, and libs folders.
This commit is contained in:
parent
24de55e45a
commit
d0b12e92e7
362 changed files with 21716 additions and 7018 deletions
50
libs/rtmpserver/node_rtmp_server.js
Normal file
50
libs/rtmpserver/node_rtmp_server.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
//
|
||||
// Created by Mingliang Chen on 17/8/1.
|
||||
// illuspas[a]gmail.com
|
||||
// Copyright (c) 2018 Nodemedia. All rights reserved.
|
||||
//
|
||||
// const Logger = require('./node_core_logger');
|
||||
|
||||
const Net = require('net');
|
||||
const NodeRtmpSession = require('./node_rtmp_session');
|
||||
const NodeCoreUtils = require('./node_core_utils');
|
||||
|
||||
const context = require('./node_core_ctx');
|
||||
|
||||
const RTMP_PORT = 1935;
|
||||
|
||||
class NodeRtmpServer {
|
||||
constructor(config) {
|
||||
config.rtmp.port = this.port = config.rtmp.port ? config.rtmp.port : RTMP_PORT;
|
||||
this.tcpServer = Net.createServer((socket) => {
|
||||
let session = new NodeRtmpSession(config, socket);
|
||||
session.run();
|
||||
})
|
||||
}
|
||||
|
||||
run() {
|
||||
this.tcpServer.listen(this.port, () => {
|
||||
// Logger.log(`Node Media Rtmp Server started on port: ${this.port}`);
|
||||
});
|
||||
|
||||
this.tcpServer.on('error', (e) => {
|
||||
// Logger.error(`Node Media Rtmp Server ${e}`);
|
||||
});
|
||||
|
||||
this.tcpServer.on('close', () => {
|
||||
// Logger.log('Node Media Rtmp Server Close.');
|
||||
});
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.tcpServer.close();
|
||||
context.sessions.forEach((session, id) => {
|
||||
if (session instanceof NodeRtmpSession) {
|
||||
session.socket.destroy();
|
||||
context.sessions.delete(id);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NodeRtmpServer
|
Loading…
Add table
Add a link
Reference in a new issue