获取 id 未定义的错误。如果我使用0.peerjs.com
它就可以了。这是客户端代码:
var peer = new Peer({
host: 'vchat247.hopto.org',
port: 9000,
path: '/peer/',
debug: 3,
config: {
'iceServers': [
{url: 'stun:stun1.l.google.com:19302'},
{
url: 'turn:numb.viagenie.ca',
credential: 'muazkh', username: 'webrtc@live.com'
}
]
}
});
这是我自己的peer-server
代码:
var fs = require('fs');
var PeerServer = require('peer').PeerServer;
var server = PeerServer({
port: 9000,
path: '/peer/',
ssl: {
key: fs.readFileSync('./myserver.key'),
certificate: fs.readFileSync('./vchat247.hopto.org.crt')
}
});
我究竟做错了什么?
如果我使用这段代码:
function randomString(length, chars) {
var result = '';
for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
return result;
}
var peer = new Peer(randomString(16, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), {host: 'vchat247.hopto.org', port: 9000, path: '/peer/'});