-
Notifications
You must be signed in to change notification settings - Fork 3
Opentok service
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>
- Initializes a publisher
- Returns observable publisher object
call():Observable<boolean>
- Publishes the new publisher to the active session
- Returns always observable with value true
hangUp():void
- Stops publishing streams to session
- Unsubscribes local subscriber from the current session
- Stops listening to all events in the current session
- Disconnects from the session
- Stops listening to all publisher events
- Destroys publisher
- Stops listening to all subscriber events
publishVideo(show: boolean):void
onIncomingCall(subscriberTag?: string, subscriberProperties?: {}): Observable<OTStreamEvent>
- Listens to streamCreated event and subscribes to the stream
- Returns OTStreamEvent as an observable value.
onEndCall(): Observable<OTConnectionEvent>
- Listens to connectionDestroyed events
- Returns OTConnectionEvent as an observable value.
onNetworkFailedForPublisher(): Observable<OTSessionDisconnectEvent>
- Listens to sessionDisconnected events and filters them by the reason networkDissconnected
- Returns OTSessionDisconnectEvent as an observable value.
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>
- Sends signal to everybody in the session
- Returns always observable with value true
onSignal(signalType?: string):Observable<OTSignalEvent>
onReconnecting(): Observable<OTEvent>
- Listens to sessionReconnecting event
- Returns a basic event
onReconnected(): Observable<OTEvent>
- Listens to sessionReconnected event
- Returns a basic event
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.