From 5929be5c108d203d34579c2cc2e72562c1393e49 Mon Sep 17 00:00:00 2001 From: Ethan Look Date: Mon, 13 May 2024 14:08:31 -0400 Subject: [PATCH] RSDK-7244: Expose data channel so TS SDK can listen for disconnect (#287) --- rpc/examples/echo/frontend/package-lock.json | 2 +- rpc/js/package-lock.json | 4 ++-- rpc/js/package.json | 2 +- rpc/js/src/dial.ts | 9 ++++++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/rpc/examples/echo/frontend/package-lock.json b/rpc/examples/echo/frontend/package-lock.json index 47f0ce7a..b1a74bdf 100644 --- a/rpc/examples/echo/frontend/package-lock.json +++ b/rpc/examples/echo/frontend/package-lock.json @@ -26,7 +26,7 @@ }, "../../../js": { "name": "@viamrobotics/rpc", - "version": "0.2.4", + "version": "0.2.5", "license": "Apache-2.0", "dependencies": { "@improbable-eng/grpc-web": "^0.13.0", diff --git a/rpc/js/package-lock.json b/rpc/js/package-lock.json index ca7b5419..1954dde4 100644 --- a/rpc/js/package-lock.json +++ b/rpc/js/package-lock.json @@ -1,12 +1,12 @@ { "name": "@viamrobotics/rpc", - "version": "0.2.4", + "version": "0.2.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@viamrobotics/rpc", - "version": "0.2.4", + "version": "0.2.5", "license": "Apache-2.0", "dependencies": { "@improbable-eng/grpc-web": "^0.13.0", diff --git a/rpc/js/package.json b/rpc/js/package.json index 7f55c5ef..d97a3686 100644 --- a/rpc/js/package.json +++ b/rpc/js/package.json @@ -1,6 +1,6 @@ { "name": "@viamrobotics/rpc", - "version": "0.2.4", + "version": "0.2.5", "license": "Apache-2.0", "dependencies": { "@improbable-eng/grpc-web": "^0.13.0", diff --git a/rpc/js/src/dial.ts b/rpc/js/src/dial.ts index fab7d7cf..345b9a1f 100644 --- a/rpc/js/src/dial.ts +++ b/rpc/js/src/dial.ts @@ -265,6 +265,7 @@ class authenticatedTransport implements grpc.Transport { export interface WebRTCConnection { transportFactory: grpc.TransportFactory; peerConnection: RTCPeerConnection; + dataChannel: RTCDataChannel; } async function getOptionalWebRTCConfig( @@ -319,6 +320,8 @@ async function getOptionalWebRTCConfig( // PeerConnection itself. Care should be taken with the PeerConnection and is currently returned for experimental // use. // TODO(GOUT-7): figure out decent way to handle reconnect on connection termination +// eslint-disable-next-line sonarjs/cognitive-complexity +// eslint-disable-next-line func-style export async function dialWebRTC( signalingAddress: string, host: string, @@ -637,7 +640,11 @@ export async function dialWebRTC( } successful = true; - return { transportFactory: cc.transportFactory(), peerConnection: pc }; + return { + transportFactory: cc.transportFactory(), + peerConnection: pc, + dataChannel: dc, + }; } finally { if (!successful) { pc.close();