forked from Shiloh/remnantchat
feat: define makeAction
This commit is contained in:
parent
2ec8c52f7c
commit
9c3e96a804
32
src/react-app-env.d.ts
vendored
32
src/react-app-env.d.ts
vendored
@ -25,21 +25,29 @@ declare module 'trystero' {
|
||||
export type RoomConfig = BaseRoomConfig &
|
||||
(BitTorrentRoomConfig | FirebaseRoomConfig | IpfsRoomConfig)
|
||||
|
||||
export type ActionSender = <T>(
|
||||
data: T,
|
||||
targetPeers?: string[],
|
||||
metadata?: Record,
|
||||
progress: (percent: number, peerId: string) => void
|
||||
) => void
|
||||
|
||||
export type ActionReceiver = <T>(
|
||||
data: T,
|
||||
peerId: string,
|
||||
metadata?: Record
|
||||
) => void
|
||||
|
||||
export type ActionProgress = (
|
||||
percent: number,
|
||||
peerId: string,
|
||||
metadata?: Record
|
||||
) => void
|
||||
|
||||
export interface Room {
|
||||
makeAction: <T>(
|
||||
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<T>, ActionReceiver<T>, ActionProgress]
|
||||
|
||||
ping: (id: string) => Promise<number>
|
||||
|
||||
|
@ -18,4 +18,8 @@ export class PeerRoom {
|
||||
this.room.leave()
|
||||
}
|
||||
}
|
||||
|
||||
makeAction<T>(namespace: string) {
|
||||
return this.room?.makeAction<T>(namespace)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user