代码拉取完成,页面将自动刷新
//
// 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.stop();
});
}
}
module.exports = NodeRtmpServer
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。