Skip to content

Opentok service

Snezana edited this page Nov 30, 2017 · 14 revisions

Opentok service currently supports video chat only between two entities.

It can be used to shorten the implementation logic for the developers, BUT is not required. You can use the models directly, according to your own needs.

This service offers the methods necessary to handle the basic flow of a video chat. Some of the methods from the Opentok.js library are combined in one method in a flow required from the documentation. This service basically adds an abstraction layer to eliminate the extra implementations for the developers.

Here is the documentation of the offered methods:

isWebRTCSupported():boolean

connectToSession(sessionId: string, token: string):Observable<OTSession>

  • Initializes a session for the given session id
  • Connects to the session with the specified token
  • Returns the new session to which a connection was established as an observable value.

initCaller(publisherTag?: string, publisherProperties?: {}): Observable<OTPublisher>

call():Observable<boolean>

hangUp():void

publishVideo(show: boolean):void

onIncomingCall(subscriberTag?: string, subscriberProperties?: {}): Observable<OTStreamEvent>

onEndCall(): Observable<OTConnectionEvent>

onNetworkFailedForPublisher(): Observable<OTSessionDisconnectEvent>

getSubscriberScreenshot():string

onVideoChanged(): Observable<OTStreamPropertyChangedEvent>

  • Listens to streamPropertyChanged event and filters only the video value changes
  • Returns OTStreamPropertyChangedEvent as an observable value.

sendSignal(signalType?: string, data?: string): Observable<boolean>

onSignal(signalType?: string):Observable<OTSignalEvent>

onReconnecting(): Observable<OTEvent>

onReconnected(): Observable<OTEvent>

onOpenMediaAccessDialog(): Observable<OTEvent>

  • Listens to accessDialogOpened event, dispatched when the user has clicked the Allow button, granting the app access to the camera and microphone.
  • Returns a basic event

onClosedMediaAccessDialog(): Observable<OTEvent>

  • Listens to accessDialogClosed event, dispatched when the Allow/Deny box is closed. (This is the dialog box in which the user can grant the app access to the camera and microphone.)

onMediaAccessDenied(): Observable<OTEvent>

  • Listens to accessDenied event, dispatched when the user has clicked the Deny button, preventing the app from having access to the camera and microphone.
  • Returns a basic event

onMediaAccessAllowed(): Observable<OTEvent>

  • Listens to accessAllowed event, dispatched when the user has clicked the Allow button, granting the app access to the camera and microphone. The Publisher object has an accessAllowed property which indicates whether the user has granted access to the camera and microphone.
  • Returns a basic event

onAudioLevelUpdated(): Observable<OTAudioLevelUpdatedEvent>

  • Listens to audioLevelUpdated event, dispatched periodically to indicate the publisher's audio level. The event is dispatched up to 60 times per second, depending on the browser. The audioLevel property of the event is audio level, from 0 to 1.0. See AudioLevelUpdatedEvent for more information.