WebRTC Portal
Create WebRTC portals and ether
Creates configurable WebRTC portals and ether.
# Clone the repository
npm install @ceil-dev/webrtc-portal
import { createWebRTCPortal, createWebRTCEther } from '@ceil-dev/webrtc-portal';
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);
This project is licensed under the MIT License - see the LICENSE.md file for details.