我用soket.io安装了nodejs.想要将此代码测试到服务器节点server.js
var static = require('node-static');
var http = require('http');
// Create a node-static server instance listening on port 8181
var file = new(static.Server)();
// We use the http module’s createServer function and
// use our instance of node-static to serve the files
var app = http.createServer(function (req, res) {
file.serve(req, res);
}).listen(8181);
// Use socket.io JavaScript library for real-time web applications
var io = require('socket.io').listen(app);
// Let's start managing connections...
io.sockets.on('connection', function (socket){
// Handle 'message' messages
socket.on('message', function (message) …Run Code Online (Sandbox Code Playgroud)我尝试通过WebRTC socket.io测试一个视频通话和聊天练习。我无法在firefox上收到控制台错误,但无法攻击它们之间的两个本地/远程流。我的浏览器代码是这个
'use strict';
var p = navigator.mediaDevices.getUserMedia ({video: true, audio: true});
// Clean-up function:
// collect garbage before unloading browser's window
window.onbeforeunload = function(e){
hangup();
}
// Data channel information
var sendChannel, receiveChannel;
var sendButton = document.getElementById("sendButton");
var sendTextarea = document.getElementById("dataChannelSend");
var receiveTextarea = document.getElementById("dataChannelReceive");
// HTML5 <video> elements
var localVideo = document.querySelector('#localVideo');
var remoteVideo = document.querySelector('#remoteVideo');
// Handler associated with Send button
sendButton.onclick = sendData;
// Flags...
var isChannelReady = false;
var isInitiator = false;
var isStarted = …Run Code Online (Sandbox Code Playgroud)