0
我试图做非常简单的peerjs的一个页面测试,因为我知道它。Peerjs不工作..没有错误
但是,下面的代码似乎不起作用。我已经翻了三遍文件。但是在我的代码中找不到任何错误,输出也没有错误。
对于我的灵感,我用这样的:http://cdn.peerjs.com/demo/helloworld.html
我的代码
var p1 = new Peer('a351TxFJLKnljhl22',{key: 'key'});
var p2 = new Peer('a351TxFJLKnljhl22',{key: 'key'});
p1.on('open', function(id) {
console.log('connected to server');
var c = p1.connect('a351TxFJLKnljhl22');
c.on('open', function(data) {
console.log('connected to peer');
c.send('connection working');
});
});
p2.on('connection', function(connection) {
connection.on('data', function(data) {
console.log('p2 speaking..got from p1: '+data);
});
});
我希望得到连接控制台工作。