Skip to content

Commit

Permalink
Update getConnectionHandlerPeerJS.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezcarlosjr committed Jun 8, 2023
1 parent 8438422 commit df46c64
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/notebook/shell/getConnectionHandlerPeerJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ import {PeerJSOption, Peer, DataConnection} from "peerjs";
function setupConnection<T>(dataConnection: DataConnection&{id: string}, globalResponse$: Subject<any>, globalMessage$: Subject<any>, globalConnect$: Subject<any>, globalDisconnect$: Subject<any>, globalError$: Subject<any>) {
dataConnection.id = dataConnection.peer;
dataConnection.on('open', function () {
globalConnect$.next(dataConnection as DataConnection & { id: string });
// @ts-ignore
const metadata = JSON.parse(dataConnection.metadata?.toString() ?? "{}");
// @ts-ignore
if (!metadata?.ignore) {
globalConnect$.next(dataConnection as DataConnection & { id: string });
}
});
dataConnection.on('data', (messageOrResponse: any) => {
try {
messageOrResponse = JSON.parse(messageOrResponse.toString());
} catch (e) {
}
if (messageOrResponse?.message.result) {
if (messageOrResponse?.message?.result) {
globalResponse$.next({
peer: dataConnection as DataConnection & { id: string },
// @ts-ignore
Expand Down

0 comments on commit df46c64

Please sign in to comment.