mirror of
https://api.glitch.com/git/yaswvc
synced 2026-01-12 03:18:10 +00:00
🎨🌄 Checkpoint
./public/main.js:5975361/1046
This commit is contained in:
parent
f726b2589f
commit
a1c20c43e8
1 changed files with 17 additions and 5 deletions
|
|
@ -9,6 +9,7 @@ var app = new Vue({
|
|||
}),
|
||||
stream: null,
|
||||
calls: [],
|
||||
connections: [],
|
||||
},
|
||||
methods: {
|
||||
logMessage: function(message) {
|
||||
|
|
@ -24,12 +25,21 @@ var app = new Vue({
|
|||
this.logMessage(`Connecting to ${peerId}...`);
|
||||
|
||||
let conn = this.peer.connect(peerId);
|
||||
this.connections.push(conn);
|
||||
console.log('[Out] connected', conn);
|
||||
conn.on('data', (data) => {
|
||||
this.logMessage(`received: ${data}`);
|
||||
});
|
||||
conn.on('open', () => {
|
||||
conn.send('hi!');
|
||||
});
|
||||
conn.on('close', () => {
|
||||
this.connections = this.connections.filter(c => c.connectionId === conn.connectionId);
|
||||
console.log('[Out] Connection closed', conn.connectionId);
|
||||
});
|
||||
conn.on('error', () => {
|
||||
console.warn(`[Out] Connection error ${conn.connectionId} with ${conn.peer}.`);
|
||||
});
|
||||
|
||||
let call = this.peer.call(peerId, this.stream);
|
||||
call.on('stream', (stream) => this.renderVideo(stream, '#video-'+call.connectionId));
|
||||
|
|
@ -61,7 +71,8 @@ var app = new Vue({
|
|||
// Handle incoming data connection
|
||||
this.peer.on('connection', (conn) => {
|
||||
this.logMessage('incoming peer connection!');
|
||||
console.log('incoming peer connection!', conn);
|
||||
this.connections.push(conn);
|
||||
console.log('[INC] incoming peer connection!', conn);
|
||||
conn.on('data', (data) => {
|
||||
this.logMessage(`received: ${data}`);
|
||||
});
|
||||
|
|
@ -69,11 +80,12 @@ var app = new Vue({
|
|||
conn.send('hello!');
|
||||
});
|
||||
conn.on('close', () => {
|
||||
this.connections = this.connections.filter(c => c.connectionId === conn.connectionId);
|
||||
this.logMessage('Connection closed.');
|
||||
console.log('[Inc] closed conenction', conn)
|
||||
});
|
||||
conn.on('error', (error) => {
|
||||
console.error('Error:', error);
|
||||
this.logMessage('Error'+error);
|
||||
conn.on('error', () => {
|
||||
console.warn(`[Inc] Connection error ${conn.connectionId} with ${conn.peer}.`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue