Commit 7f6f5ccc by Christoph

updated dependencies & bugfixes

* updated version number to the latest asset version 0.984.4 * updated npm dependencies for security fixes * updated to ES2016 libraries. Java Script output needs to remain on ES2015 though as Unity 2019.2 builds will fail otherwise * Bugfix: Make sure all connections are cut on shutdown. In experimental conference mode some connections could remain active after shutdown if some references were kept alive * Made sure the disconnect method will check the actual id not expect the exact reference of the internal ConnectionId * added warnings if the user tries to send invalid messages (0 length, null or invalid message id)
parent 58a4ab20
{
"name": "awrtc_browser",
"version": "0.984.0",
"version": "0.984.4",
"description": "",
"author": "because-why-not.com Limited",
"license": "BSD-3-Clause",
"dependencies": {},
"main": "build/awrtc/index.js",
"types": "build/awrtc/index.d.ts",
"scripts": {
"tsc": "tsc",
"webpack": "webpack",
......@@ -14,19 +16,19 @@
"devDependencies": {
"@types/jasmine": "^2.8.16",
"jasmine": "^2.99.0",
"jasmine-core": "^3.4.0",
"karma": "^4.2.0",
"jasmine-core": "^3.5.0",
"karma": "^4.4.1",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.2.0",
"karma-firefox-launcher": "^1.3.0",
"karma-jasmine": "^2.0.1",
"shx": "^0.3.2",
"source-map-loader": "^0.2.4",
"ts-loader": "^5.4.5",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"typescript": "^3.5.3",
"typescript": "^3.8.2",
"uglify-js": "^2.8.29",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.6",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11",
"webrtc-adapter": "^6.4.8"
}
}
......@@ -255,6 +255,13 @@ export class CallApp
let messageArgs = args as awrtc.DataMessageEventArgs;
this.mCall.SendData(messageArgs.Content, messageArgs.Reliable, messageArgs.ConnectionId);
}
else if (args.Type == awrtc.CallEventType.CallAccepted) {
let arg = args as awrtc.CallAcceptedEventArgs;
console.log("New call accepted id: " + arg.ConnectionId.id);
}
else if (args.Type == awrtc.CallEventType.WaitForIncomingCall) {
console.log("Waiting for incoming call ...");
}
else {
console.log("Unhandled event: " + args.Type);
}
......
......@@ -172,7 +172,9 @@ export class WebRtcNetwork implements IBasicNetwork {
}
public Shutdown(): void {
for (var id of this.mConnectionIds) {
//bugfix. Make copy before the loop as Disconnect changes the original mConnectionIds array
let ids = this.mConnectionIds.slice();
for (var id of ids) {
this.Disconnect(id);
}
this.StopServer();
......@@ -374,12 +376,14 @@ export class WebRtcNetwork implements IBasicNetwork {
if (peer) {
peer.Dispose();
}
//??? this looks buggy. the connection id could be a reference with the same id and would not be recognized
let index = this.mConnectionIds.indexOf(id);
//search for the index to remove the id (user might provide a different object with the same id
//don't use indexOf!
let index = this.mConnectionIds.findIndex( e => e.id == id.id);
if (index != -1) {
this.mConnectionIds.splice(index, 1);
}
delete this.mIdToConnection[id.id];
}
let ev = new NetworkEvent(NetEventType.Disconnected, id, null);
this.mEvents.Enqueue(ev);
}
......
......@@ -138,10 +138,12 @@ export abstract class AWebRtcPeer {
private SetupPeer(rtcConfig: RTCConfiguration): void {
this.mPeer = new RTCPeerConnection(rtcConfig);
this.mPeer.onicecandidate = (ev: RTCPeerConnectionIceEvent) => { this.OnIceCandidate(ev); };
this.mPeer.oniceconnectionstatechange = (ev: Event) => { this.OnIceConnectionChange(); };
this.mPeer.onnegotiationneeded = (ev: Event) => { this.OnRenegotiationNeeded(); };
this.mPeer.onsignalingstatechange = (ev: Event) => { this.OnSignalingChange(); };
this.mPeer.onicecandidate = this.OnIceCandidate;
this.mPeer.oniceconnectionstatechange = this.OnIceConnectionStateChange;
this.mPeer.onconnectionstatechange = this.OnConnectionStateChange;
this.mPeer.onicegatheringstatechange = this.OnIceGatheringStateChange;
this.mPeer.onnegotiationneeded = this.OnRenegotiationNeeded;
this.mPeer.onsignalingstatechange = this.OnSignalingChange;
}
......@@ -399,12 +401,17 @@ export abstract class AWebRtcPeer {
}
protected RtcSetClosed(): void {
if (this.mRtcInternalState == WebRtcInternalState.Connected)
{
Debug.Log("triggering closure");
this.mRtcInternalState = WebRtcInternalState.Closed;
}
}
private OnIceCandidate(ev: RTCPeerConnectionIceEvent): void {
private OnIceCandidate = (ev: RTCPeerConnectionIceEvent): void =>
{
if (ev && ev.candidate) {
let candidate = ev.candidate;
let msg: string = JSON.stringify(candidate);
......@@ -412,9 +419,13 @@ export abstract class AWebRtcPeer {
}
}
private OnIceConnectionChange(): void {
Debug.Log(this.mPeer.iceConnectionState);
if (this.mPeer.iceConnectionState == "failed") {
private OnIceConnectionStateChange = (ev: Event): void =>
{
Debug.Log("on ice connection state: " + this.mPeer.iceConnectionState);
//Chrome stopped emitting "failed" events. We have to react to disconnected events now
if (this.mPeer.iceConnectionState == "failed" || this.mPeer.iceConnectionState == "disconnected")
{
if(this.mState == WebRtcPeerState.Signaling)
{
this.RtcSetSignalingFailed();
......@@ -425,15 +436,27 @@ export abstract class AWebRtcPeer {
}
}
private OnIceGatheringChange(/*new_state: RTCIceGatheringState*/): void {
Debug.Log(this.mPeer.iceGatheringState);
/*
So far useless. never triggered in firefox.
In Chrome it triggers together with the DataChannels opening which might be more useful in the future
*/
private OnConnectionStateChange = (ev:Event): void =>
{
//Debug.Log("on connection state change: " + this.mPeer.iceConnectionState);
}
private OnIceGatheringStateChange = (ev:Event): void =>
{
//Debug.Log("ice gathering change: " + this.mPeer.iceGatheringState);
}
private OnRenegotiationNeeded(): void
private OnRenegotiationNeeded = (ev:Event): void =>
{ }
private OnSignalingChange(/*new_state: RTCSignalingState*/): void {
Debug.Log(this.mPeer.signalingState);
//broken in chrome. won't switch to closed anymore
private OnSignalingChange = (ev:Event): void =>
{
Debug.Log("on signaling change:" + this.mPeer.signalingState);
if (this.mPeer.signalingState == "closed") {
this.RtcSetClosed();
}
......
......@@ -438,8 +438,17 @@ export class WebsocketNetwork implements IBasicNetwork {
this.HandleOutgoingEvents();
}
public SendData(id: ConnectionId, data: Uint8Array, /*offset: number, length: number,*/ reliable: boolean): boolean {
if (id == null || data == null || data.length == 0)
if (id == null || id.id == ConnectionId.INVALID.id)
{
SLog.LW("Ignored message. Invalid connection id.");
return;
}
if (data == null || data.length == 0)
{
SLog.LW("Ignored message. Invalid data.");
return;
}
var evt: NetworkEvent;
if (reliable) {
evt = new NetworkEvent(NetEventType.ReliableMessageReceived, id, data);
......
......@@ -3,6 +3,7 @@
"compilerOptions": {
"declaration": true,
"target": "es5",
"lib" : ["ES2016", "dom"],
"module": "es2015",
"outDir": "../../build/awrtc"
}
......
......@@ -71,6 +71,15 @@ describe("DeviceApiTest", () => {
deviceCount = Object.keys(devices1).length;
expect(deviceCount).toBeGreaterThan(0);
let key1 = Object.keys(devices1)[0];
//these tests don't work anymore due to forcing permissions for devices in
//unit tests.
//In a real browser we don't have access to device names until GetUserMedia
//returned. Meaning the API will fill in the names using "videoinput 1"
//"videoinput 2" and so on.
//Now the tests force permissions = true so we already have full
//access at the start
/*
expect(devices1[key1].label).toBe("videoinput 1");
expect(devices1[key1].isLabelGuessed).toBe(true);
if(deviceCount > 1)
......@@ -79,6 +88,7 @@ describe("DeviceApiTest", () => {
expect(devices1[key2].label).toBe("videoinput 2");
expect(devices1[key2].isLabelGuessed).toBe(true);
}
*/
DeviceApi.RemOnChangedHandler(updatecall1);
......
......@@ -6,6 +6,7 @@
"removeComments": false,
"sourceMap": true,
"target": "es5",
"lib" : ["ES2016", "dom"],
"module": "es2015",
"declaration": false,
"outDir": "../build/test",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment