UNPKG

vroom-web-sdk-beta

Version:

VROOM SDK (beta) by True Virtual World

208 lines (175 loc) 4.19 kB
export abstract class BaseTransaction { transaction?: string body: any } export class CreateSession extends BaseTransaction { janus = 'create' constructor() { super() } } export class DestroySession extends BaseTransaction { janus = 'destroy' session_id: number constructor({ session_id }: { [id: string]: any}) { super() this.session_id = session_id } } export class AttachPluginMessage extends BaseTransaction { janus = 'attach' plugin = 'janus.plugin.videoroom' session_id: number opaque_id: string constructor({ session_id, opaque }: { [id: string]: any}) { super() this.opaque_id = opaque this.session_id = session_id } } export class TrickleMessage extends BaseTransaction { janus = 'trickle' session_id: number handle_id: number candidate: RTCIceCandidate constructor({ session_id, handle_id, candidate }: { [id: string]: any}) { super() this.session_id = session_id this.handle_id = handle_id this.candidate = candidate } } export class StartRoomMessage extends BaseTransaction { janus = 'message' session_id: number handle_id: number body: any jsep: any constructor(data: { [id: string]: any}) { super() const { session_id, handle_id, room, jsep } = data this.session_id = session_id this.handle_id = handle_id this.body = { request: 'start', room } this.jsep = jsep } } export class DetachPluginMessage extends BaseTransaction { janus = 'detach' session_id: number handle_id: number constructor({ session_id, handle_id }: { [id: string]: any}) { super() this.session_id = session_id this.handle_id = handle_id } } export class JoinRoomAsPublisher extends BaseTransaction { janus = 'message' body: any session_id: number handle_id: number constructor({ session_id, handle_id, room, display, audio, video }: any) { super() this.session_id = session_id this.handle_id = handle_id this.body = { request: 'join', ptype: 'publisher', room: room, display: display, mute_audio: audio, mute_video: video, //access_token: } } } export class JoinRoomAsSubscriber extends BaseTransaction { janus = 'message' body: any session_id: number handle_id: number constructor({ session_id, handle_id, room, streams, private_id }: any) { super() this.session_id = session_id this.handle_id = handle_id this.body = { request: 'join', ptype: 'subscriber', room: room, streams, private_id } } } export class UpdateSubscriber extends BaseTransaction { janus = 'message' body: any session_id: number handle_id: number constructor({ session_id, handle_id, body }: any) { super() this.session_id = session_id this.handle_id = handle_id this.body = body } } export class HeartBeat extends BaseTransaction { janus = 'keepalive' session_id: number constructor({ session_id }: { [id: string]: any}) { super() this.session_id = session_id as number } } export class SendOffer extends BaseTransaction { janus = 'message' session_id: number handle_id: number body: any jsep: any constructor({ session_id, handle_id, body, jsep }: any) { super() this.session_id = session_id this.handle_id = handle_id this.body = body this.jsep = jsep } } export class MuteAudio extends BaseTransaction { janus = 'message' session_id: number handle_id: number body: {[id: string]: any} constructor({ session_id, handle_id, mute, room, id }: any){ super() this.session_id = session_id this.handle_id = handle_id this.body = { request: 'mute_audio', mute_audio: mute, room, id } } } export class MuteVideo extends BaseTransaction { janus = 'message' session_id: number handle_id: number body: {[id: string]: any} constructor({ session_id, handle_id, mute, room, id }: any){ super() this.session_id = session_id this.handle_id = handle_id this.body = { request: 'mute_video', mute_video: mute, room, id } } }