@ceil-dev/webrtc-portal
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

Microenv

WebRTC Portal
Create WebRTC portals and ether


Table of Contents

  1. Overview
  2. Installation
  3. Usage
  4. Example
  5. License

Overview

Creates configurable WebRTC portals and ether.


Installation

# Clone the repository
npm install @ceil-dev/webrtc-portal

Usage

import { createWebRTCPortal, createWebRTCEther } from '@ceil-dev/webrtc-portal';

Example

Run this example in an environment with built-in RTCPeerConnection class or use a library. Also for signalling install @ceil-dev/web-point-portal or use other available or custom Ethers.

import { createWebPointEther } from '@ceil-dev/web-point-portal';
import { createWebRTCPortal, createWebRTCEther } from '@ceil-dev/webrtc-portal';

const run = async () => {
  const portalB = createPortal(
    microEnv(
      // the object to expose
      { 
        foo: 'not bar',
        sayHi: (msg: string) => console.log(msg)
      },
      { id: 'INSERT_YOUR_UNIQUE_ID' },
    ),
    [
      createWebRTCEther({
        signallingEther: createWebPointEther({ fetchMethod: fetch }),
        createRTCPeerConnection: (conf) => new RTCPeerConnection(conf),
      }),
      {
        guest: async ({ payload: { id }, portal }) => {
          console.log(portalB.descriptor.id, 'visited by', id);
        },
      },
    ]
  );

  await portalB('open');

  // Enter this portal using other WebRTC portal or Portals App (https://ceil.dev/apps#portals)
};

run().catch(console.warn);

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i @ceil-dev/webrtc-portal

Weekly Downloads

111

Version

0.1.6

License

none

Unpacked Size

43.5 kB

Total Files

23

Last publish

Collaborators

  • serg.shkatula
  • philipp.sh