implemented disconnect/reconnect in webrtc connector. adapted the example gc also collects child elements (needs improvements)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* global Y */
|
||||
/* global Y, SimpleWebRTC */
|
||||
'use strict'
|
||||
|
||||
class WebRTC extends Y.AbstractConnector {
|
||||
@@ -11,21 +11,16 @@ class WebRTC extends Y.AbstractConnector {
|
||||
}
|
||||
options.role = 'slave'
|
||||
super(y, options)
|
||||
|
||||
var room = options.room
|
||||
|
||||
var webrtcOptions = {
|
||||
this.webrtcOptions = {
|
||||
url: options.url || 'https://yatta.ninja:8888',
|
||||
room: options.room
|
||||
}
|
||||
|
||||
var swr = new SimpleWebRTC(webrtcOptions) // eslint-disable-line no-undef
|
||||
var swr = new SimpleWebRTC(this.webrtcOptions)
|
||||
this.swr = swr
|
||||
var self = this
|
||||
|
||||
swr.once('connectionReady', function (userId) {
|
||||
// SimpleWebRTC (swr) is initialized
|
||||
swr.joinRoom(room)
|
||||
swr.joinRoom(self.webrtcOptions.room)
|
||||
|
||||
swr.once('joinedRoom', function () {
|
||||
self.setUserId(userId)
|
||||
@@ -61,6 +56,14 @@ class WebRTC extends Y.AbstractConnector {
|
||||
})
|
||||
})
|
||||
}
|
||||
disconnect () {
|
||||
this.swr.leaveRoom()
|
||||
super.disconnect()
|
||||
}
|
||||
reconnect () {
|
||||
this.swr.joinRoom(this.webrtcOptions.room)
|
||||
super.reconnect()
|
||||
}
|
||||
send (uid, message) {
|
||||
var self = this
|
||||
// we have to make sure that the message is sent under all circumstances
|
||||
|
||||
Reference in New Issue
Block a user