Home Reference Source
import Selfie from '@quobis/sippojs'
public class | source

Selfie

Extends:

src/eventemitter.js~EventEmitter → Selfie

Provides access to methods for controlling a selfie. This class must not be directly instantiated. It can be obtained using session#createSelfie or listening to session#selfie-invite event.

Events

  • cancel is emitted when the selfie has been finished.
  • image is emitted when the image is received.
  • taking is emitted when the remote user is taking a picture.

You can check EventEmitter2 documentation for additional information about adding and removing listeners for this events events.

See:

Example:

How to create a Selfie
// 1. Agent side create a selfie using session object.
let selfie = session.createSelfie(['user@domain']);
// 2. Client listens to 'selfie-invite event'
session.on('selfie-invite', function(selfie){
 // ... do stuff with selfie.
})
Notify the agent that user is taking a selfie
// Agent will receive 'taking' event.
selfie.on('taking', () => {...});
// Client just calls selfie method.
selfie.notifyTaking();
Send the picture to the agent
// Agent will receive 'image' event.
selfie.on('image', (imageURL) => {...});
// Client just calls selfie method.
selfie.send(imageURL);

Static Member Summary

Static Public Members
public static get

The version of the protocol implemented.

Member Summary

Public Members
public get

Method Summary

Public Methods
public

Cancel the process at any time.

public

Send 'taking' event to the other side.

public

send(imgDataUrl: imgDataUrl): Promise

Send the image to the agent.

Static Public Members

public static get PROTOCOL: string source

The version of the protocol implemented.

Public Members

public get isConnected: * source

Public Methods

public cancel(): Promise source

Cancel the process at any time.

Return:

Promise

A promise that is fulfilled when the selfie is canceled.

public notifyTaking(): Promise source

Send 'taking' event to the other side.

Return:

Promise

A promise that is fulfilled when the notification has been sent.

public send(imgDataUrl: imgDataUrl): Promise source

Send the image to the agent. This can be a regular URL or a dataUrl, with a base64 encoded image.

Params:

NameTypeAttributeDescription
imgDataUrl imgDataUrl

The image file containing the selfie.

Return:

Promise

A promise that is fulfilled when the image has been sent.