diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index cfadd2d..cdd6063 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -25,21 +25,29 @@ declare module 'trystero' { export type RoomConfig = BaseRoomConfig & (BitTorrentRoomConfig | FirebaseRoomConfig | IpfsRoomConfig) + export type ActionSender = ( + data: T, + targetPeers?: string[], + metadata?: Record, + progress: (percent: number, peerId: string) => void + ) => void + + export type ActionReceiver = ( + data: T, + peerId: string, + metadata?: Record + ) => void + + export type ActionProgress = ( + percent: number, + peerId: string, + metadata?: Record + ) => void + export interface Room { makeAction: ( namespace: string - ) => [ - ( - data: T, - targetPeers?: string[], - metadata?: Record, - progress: (percent: number, peerId: string) => void - ) => void, - - (data: T, peerId: string, metadata?: Record) => void, - - (percent: number, peerId: string, metadata?: Record) => void - ] + ) => [ActionSender, ActionReceiver, ActionProgress] ping: (id: string) => Promise diff --git a/src/services/PeerRoom/PeerRoom.ts b/src/services/PeerRoom/PeerRoom.ts index 6cf9586..ea1a291 100644 --- a/src/services/PeerRoom/PeerRoom.ts +++ b/src/services/PeerRoom/PeerRoom.ts @@ -18,4 +18,8 @@ export class PeerRoom { this.room.leave() } } + + makeAction(namespace: string) { + return this.room?.makeAction(namespace) + } }