@oiij/use
Version:
Som Composable Functions for Vue 3
52 lines (51 loc) • 1.46 kB
text/typescript
import * as vue62 from "vue";
import * as _vueuse_core30 from "@vueuse/core";
//#region src/composables/use-web-rtc.d.ts
type WebRTCOptions = RTCConfiguration & {
protocols?: string[];
};
type Status = 'pending' | 'ready' | 'connected' | 'closed';
type HandleEvent = {
'register': {
payload: {
key: string;
};
};
'offer': {
payload: {
key: string;
desc: RTCSessionDescriptionInit;
};
};
'answer': {
payload: {
key: string;
desc: RTCSessionDescriptionInit;
};
};
'answer-ok': {
payload: {
key: string;
};
};
'ice-candidate': {
payload: {
candidate: RTCIceCandidate;
};
};
};
declare function useWebRTC(url: string | URL, options?: WebRTCOptions): {
id: vue62.Ref<string | undefined, string | undefined>;
connected: vue62.Ref<string[], string[]>;
status: vue62.Ref<Status, Status>;
peer: RTCPeerConnection;
signalingState: vue62.Ref<RTCSignalingState, RTCSignalingState>;
connectionState: vue62.Ref<RTCPeerConnectionState, RTCPeerConnectionState>;
connect: (id: string, label?: string) => Promise<RTCDataChannel>;
connectStream: (id: string, stream: MediaStream) => Promise<RTCPeerConnection>;
onReady: _vueuse_core30.EventHookOn<void>;
onConnection: _vueuse_core30.EventHookOn<RTCDataChannelEvent>;
onConnectionStream: _vueuse_core30.EventHookOn<RTCTrackEvent>;
};
//#endregion
export { HandleEvent, Status, WebRTCOptions, useWebRTC };