@oiij/web-rtc
Version:
Features:
26 lines (23 loc) • 944 B
text/typescript
import * as vue from 'vue';
type Options = RTCConfiguration & {
host?: string;
port?: number;
path?: string;
protocols?: string[];
};
type Status = 'pending' | 'ready' | 'connected' | 'closed';
declare function useWebRTC(options?: Options): {
id: vue.Ref<string | undefined, string | undefined>;
connected: vue.Ref<string[], string[]>;
status: vue.Ref<Status, Status>;
ws: WebSocket;
peer: RTCPeerConnection;
signalingState: vue.Ref<RTCSignalingState, RTCSignalingState>;
connectionState: vue.Ref<RTCPeerConnectionState, RTCPeerConnectionState>;
onReady: (fn: () => void) => void;
connect: (id: string, label?: string) => Promise<RTCDataChannel>;
onConnection: (fn: (ev: RTCDataChannelEvent) => void) => void;
connectStream: (id: string, stream: MediaStream) => Promise<RTCPeerConnection>;
onConnectionStream: (fn: (ev: RTCTrackEvent) => void) => void;
};
export { useWebRTC };