Skip to content

Commit

Permalink
RSDK-7244: Expose data channel so TS SDK can listen for disconnect (v…
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanlookpotts authored May 13, 2024
1 parent 612b3f8 commit 5929be5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rpc/examples/echo/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions rpc/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/js/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 8 additions & 1 deletion rpc/js/src/dial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ class authenticatedTransport implements grpc.Transport {
export interface WebRTCConnection {
transportFactory: grpc.TransportFactory;
peerConnection: RTCPeerConnection;
dataChannel: RTCDataChannel;
}

async function getOptionalWebRTCConfig(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 5929be5

Please sign in to comment.