Skip to content

Commit

Permalink
chore: fix simplepeer types
Browse files Browse the repository at this point in the history
  • Loading branch information
leifriksheim committed Dec 14, 2023
1 parent 6d58f8f commit 9e7d6ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/webrtc/src/WebRTCManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ export class WebRTCManager {
* Join the chat room, listen for signals
*/
async join(initialSettings?: Settings) {
console.log("trying to join");

let settings = { audio: true, video: false, ...initialSettings };

this.localStream = await navigator.mediaDevices.getUserMedia({
Expand Down
14 changes: 8 additions & 6 deletions packages/webrtc/src/ad4mPeer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import * as SimplePeer from "simple-peer";
import SimplePeerInstance from "simple-peer/simplepeer.min.js";
import type { SimplePeer, Options, Instance } from "simple-peer";

import { Literal, NeighbourhoodProxy } from "@coasys/ad4m";

export interface AD4MPeerInstance extends SimplePeer.Instance {}
export interface AD4MPeerInstance extends Instance {}

export type Props = {
did: string;
source: string;
neighbourhood: NeighbourhoodProxy;
initiator: boolean;
stream: MediaStream;
options?: SimplePeer.Options;
options?: Options;
};

export class AD4MPeer {
Expand All @@ -20,7 +21,7 @@ export class AD4MPeer {
private source: string;
private stream: MediaStream;
private neighbourhood: NeighbourhoodProxy;
private options?: SimplePeer.Options;
private options?: Options;

constructor(props: Props) {
this.did = props.did;
Expand All @@ -32,18 +33,19 @@ export class AD4MPeer {
}

public connect() {
console.log("creating peer");
this.peer = this.createPeer();

return this.peer;
}

private createPeer(): AD4MPeerInstance {
const peer = new SimplePeer({
const peer = new SimplePeerInstance({
initiator: this.initiator,
stream: this.stream,
...this.options,
trickle: false,
});
}) as Instance;

// Local peerjs instance has data it wants to send to remote peer
peer.on("signal", (signal) => {
Expand Down

0 comments on commit 9e7d6ee

Please sign in to comment.