simpleWebRTC一種簡單的開源網頁音視頻聊天室解決方案。本文在原博客做者編寫的文檔上作了細化。node
simpleWebRTC是基於nodejs開發,所以須要先安裝nodejs。nodejs的下載地址: http://nodejs.cn/download/nodejs的在window環境的安裝比較簡單,本文再也不介紹。git
simpleWebRTC的安裝的服務軟件包括simpleWebRTC和Signalmaster。它們的下載地址以下:github
simpleWebRTC: https://github.com/HenrikJoreteg/SimpleWebRTCweb
Signalmaster: https://github.com/andyet/signalmasterexpress
打開命令窗口進入Signalmaster的根目錄執行以下命令:npm
node server.js
注意:在windows下通常會出現啓動失敗,失敗的緣由只要是Signalmaster默認監聽的8888端口已經被佔用。可用以下命令先查看8888端口是否被佔用:json
netstat -aon|findstr "8888"
若是8888端口被佔用,在到Signalmaster安裝目錄的config目中中修改development.json和production.json中的端口號配置,例如改爲8881:windows
{ "isDev": false, "server": { "port": 8881, "/* secure */": "/* whether this connects via https */", "secure": true, "key": "config/sslcerts/key.pem", "cert": "config/sslcerts/cert.pem", "password": null }, "rooms": { "/* maxClients */": "/* maximum number of clients per room. 0 = no limit */", "maxClients": 0 }, "stunservers": [ { "url": "stun:stun.l.google.com:19302" } ], "turnservers": [ { "urls": ["turn:your.turn.servers.here"], "secret": "turnserversharedsecret", "expiry": 86400 } ] }
在windows下修改端口只須要關閉窗口,從新啓動一個窗口再執行服務器
node server.js
打開命令窗口進入simpleWebRTC解壓後的根目錄執行以下兩條命令:函數
npm install express node server.js
若此時,屏幕顯示running https on port 8000 and http on 8001,就說明simpleWebRTC已經安裝完畢。你能夠經過 https://localhost:8000 或者http://localhost:8001 訪問
注意: 若是你在安裝Signalmaster時更改了信令服務的端口號,則在安裝simpleWebRTC以前須要在simpleWebRTC解壓後的根目錄下找到simplewebrtc.bundle.js,並在改文件中查找
function SimpleWebRTC(opts) {
函數的位置大概處於17904行, 而後找到配置信令服務器url,將端口修改成本身信令服務器的監聽端口。
function SimpleWebRTC(opts) { var self = this; var options = opts || {}; var config = this.config = { //url: 'https://sandbox.simplewebrtc.com:443/', url: 'http://localhost:8881', //...省略 }; //....省略 }
注意:url地址最好改爲ip地址或者域名,使用localhost會形成遠程訪問有問題。