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);
});
});
我希望得到連接控制檯工作。