Skip to content

Mafalda-SFU/Remote-Mediasoup-client-mock

Repository files navigation

Remote Mediasoup client mock

Code coverage Docs coverage npm

This project host a class with the same API of the Remote Mediasoup client. It's intended to be used for both testing purposes and as a testbed for the migration of projects currently based on Mediasoup to use the Remote Mediasoup client instead. Behavior is mostly the same that the one offered by the Remote Mediasoup client instances, being the only two differences:

  1. Remote Mediasoup client mock uses a local instance of Mediasoup instead of connecting to an instance of Remote Mediasoup server
  2. due to that, Connection WebSocket events are emulated instead of being real ones

Install

npm install --save-dev @mafalda-sfu/remote-mediasoup-client-mock

API

See API documentation.

Usage

If you already have a Mediasoup based project, to use Remote Mediasoup client mock on it you'll only need to do two changes in your project code:

  1. Replace the mediasoup import for @mafalda-sfu/remote-mediasoup-client-mock:

    - import mediasoup from 'mediasoup'
    + import RemoteMediasoupClientMock from '@mafalda-sfu/remote-mediasoup-client-mock'
  2. Create the instance of the RemoteMediasoupClientMock object, wait for its connected event, and access to the mediasoup property:

    + const remoteMediasoupClientMock = new RemoteMediasoupClientMock
    +
    + await once(remoteMediasoupClientMock, 'connected')
    +
    + const {mediasoup} = remoteMediasoupClientMock

After that, the mediasoup variable will have an object that's API compatible with the Mediasoup API provided by the Mediasoup package.