首页 > 其他 > 详细

通过www服务发布mediasoup客户端

时间:2021-06-13 01:09:23      阅读:28      评论:0      收藏:0      [点我收藏+]

 

1.引用express

2.引用serve-index

3.制定发布目录

//server_myhttps.js
use strict const https = require(https); const express = require(express); const serve_index = require(serve-index); const fs = require(fs); //用于读取证书和私钥 const option = { key: fs.readFileSync(./certs/fullchain.key), cert: fs.readFileSync(./certs/fullchain.cert) } const app = express(); app.use(serve_index(./public)); //发布目录,但目录下的文件不能获取打开 app.use(express.static(./public)); //渲染目录下的所以文件,static静态渲染,这样文件就发布出来了 const https_server = https.createServer(option,app); //options为证书和秘钥,app为express对象 https_server.listen(443,0.0.0.0);

说明:

  public目录从mediasoup-demo/server/目录下拷贝,在server运行后在mediasoup-demo/app下执行sudo gulp live(在服务器上没有浏览器时执行sudo gulp dist,在app/gulpfile.js中有说明),在server目录下生成public目录。

 

如果服务器未启动先在服务器相应目录下启动服务器

$ npm start

然后执行刚刚的nodejs代码

$ sudo node server_myhttps.js

打开chrome浏览器进入https://localhost技术分享图片

点击index.html,开始推流技术分享图片

 

 

 

 

 

通过www服务发布mediasoup客户端

原文:https://www.cnblogs.com/dyan1024/p/14878837.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!