teleportxr 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/client.js
CHANGED
|
@@ -38,7 +38,7 @@ class Client {
|
|
|
38
38
|
tick(timestamp){
|
|
39
39
|
this.geometryService.GetNodesToSend();
|
|
40
40
|
}
|
|
41
|
-
streamingConnectionStateChanged(
|
|
41
|
+
streamingConnectionStateChanged(newState)
|
|
42
42
|
{
|
|
43
43
|
//this.webRtcConnection=wrtcConn;
|
|
44
44
|
// This should have come from our own existing webRtcConnection and nowhere else.
|
|
@@ -48,7 +48,7 @@ class WebRtcConnection extends EventEmitter
|
|
|
48
48
|
|
|
49
49
|
this.messageReceivedReliableCb =options.messageReceivedReliable;
|
|
50
50
|
this.messageReceivedUnreliableCb =options.messageReceivedUnreliable;
|
|
51
|
-
|
|
51
|
+
this.connectionStateChangedCb=options.connectionStateChanged;
|
|
52
52
|
this.sendConfigMessage =options.sendConfigMessage;
|
|
53
53
|
|
|
54
54
|
|
|
@@ -80,7 +80,12 @@ class WebRtcConnection extends EventEmitter
|
|
|
80
80
|
});
|
|
81
81
|
this.reconnect();
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
connectionStateChanged()
|
|
84
|
+
{
|
|
85
|
+
if(!this.peerConnection)
|
|
86
|
+
return;
|
|
87
|
+
this.connectionStateChangedCb(this.peerConnection.connectionState);
|
|
88
|
+
}
|
|
84
89
|
reconnect()
|
|
85
90
|
{
|
|
86
91
|
this.peerConnection =new DefaultRTCPeerConnection({ sdpSemantics: 'unified-plan', 'iceServers': this.iceServers});
|
|
@@ -104,7 +109,7 @@ class WebRtcConnection extends EventEmitter
|
|
|
104
109
|
console.log("ICE candidate error: "+event.errorCode+" "+event.errorText+" "+event.port+" "+event.url);
|
|
105
110
|
});
|
|
106
111
|
|
|
107
|
-
this.peerConnection.addEventListener("connectionstatechange", this.connectionStateChanged.bind(this
|
|
112
|
+
this.peerConnection.addEventListener("connectionstatechange", this.connectionStateChanged.bind(this));
|
|
108
113
|
|
|
109
114
|
this.onIceCandidate= ({ candidate })=>
|
|
110
115
|
{
|
|
@@ -162,7 +167,6 @@ class WebRtcConnection extends EventEmitter
|
|
|
162
167
|
console.error("doOffer error: "+error.toString());
|
|
163
168
|
this.close();
|
|
164
169
|
console.log("doOffer close");
|
|
165
|
-
throw error;
|
|
166
170
|
}
|
|
167
171
|
};
|
|
168
172
|
|
|
@@ -180,6 +184,7 @@ class WebRtcConnection extends EventEmitter
|
|
|
180
184
|
var sessionDescription=new wrtc.RTCSessionDescription();
|
|
181
185
|
sessionDescription.sdp=answer;
|
|
182
186
|
sessionDescription.type="answer";
|
|
187
|
+
if(this.peerConnection)
|
|
183
188
|
await this.peerConnection.setRemoteDescription( sessionDescription);
|
|
184
189
|
};
|
|
185
190
|
this.applyRemoteCandidate = async(candidate_txt,mid,mlineindex)=>
|
|
@@ -190,6 +195,7 @@ class WebRtcConnection extends EventEmitter
|
|
|
190
195
|
sdpMLineIndex: mlineindex,
|
|
191
196
|
sdpMid: mid
|
|
192
197
|
});
|
|
198
|
+
if(this.peerConnection)
|
|
193
199
|
this.peerConnection.addIceCandidate(ice).catch((e)=>{
|
|
194
200
|
console.log(`Failure during addIceCandidate(): ${e.name}`);
|
|
195
201
|
});
|
|
@@ -207,12 +213,6 @@ class WebRtcConnection extends EventEmitter
|
|
|
207
213
|
};
|
|
208
214
|
};
|
|
209
215
|
}
|
|
210
|
-
connectionStateChanged()
|
|
211
|
-
{
|
|
212
|
-
if(!this.peerConnection)
|
|
213
|
-
return;
|
|
214
|
-
console.log("Connection State changed to: "+this.peerConnection.connectionState.toString());
|
|
215
|
-
}
|
|
216
216
|
onIceConnectionStateChange()
|
|
217
217
|
{
|
|
218
218
|
if(!this.peerConnection)
|
|
@@ -262,7 +262,7 @@ class WebRtcConnection extends EventEmitter
|
|
|
262
262
|
this.peerConnection.removeEventListener('iceconnectionstatechange', this.onIceConnectionStateChange.bind(this));
|
|
263
263
|
this.peerConnection.removeEventListener('icegatheringstatechange', this.onIceGatheringStateChange.bind(this));
|
|
264
264
|
//this.peerConnection.removeEventListener("icecandidateerror", (event) => {
|
|
265
|
-
this.peerConnection.removeEventListener("connectionstatechange", this.connectionStateChanged.bind(this
|
|
265
|
+
this.peerConnection.removeEventListener("connectionstatechange", this.connectionStateChanged.bind(this));
|
|
266
266
|
}
|
|
267
267
|
if (this.connectionTimer)
|
|
268
268
|
{
|
|
@@ -36,16 +36,16 @@ class WebRtcConnectionManager
|
|
|
36
36
|
closedListener()
|
|
37
37
|
{
|
|
38
38
|
this.deleteConnection(connection);
|
|
39
|
-
|
|
39
|
+
}
|
|
40
40
|
createConnection(clientID,connectionStateChangedcb,messageReceivedReliableCb,messageReceivedUnreliableCb)
|
|
41
|
-
|
|
41
|
+
{
|
|
42
42
|
var options=this.options;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
options.sendConfigMessage =this.sendConfigMessage;
|
|
44
|
+
|
|
45
|
+
options.messageReceivedReliable =messageReceivedReliableCb;
|
|
46
|
+
options.messageReceivedUnreliable =messageReceivedUnreliableCb;
|
|
47
|
+
options.connectionStateChanged =connectionStateChangedCb;
|
|
47
48
|
const connection = new WebRtcConnection(clientID,options);
|
|
48
|
-
connection.connectionStateChanged=connectionStateChangedcb;
|
|
49
49
|
// We will not add a "closed" listener, because only the client object will be permitted to close its connection.
|
|
50
50
|
//this.createConnection = (clientID) => this.closedListeners.set(connection, this.closedListener);
|
|
51
51
|
//connection.once('closed', this.closedListener);
|
package/package.json
CHANGED