@zckevin/webrtc-proxy-conn

0.0.6 • Public • Published

Install

npm install --save @zckevin/webrtc-proxy-conn

Config

interface Config {
    PEERJS_SERVER_HOST: string;
    PEERJS_SERVER_PORT: number;
}
  • Using .env file
  • Using variables in globalThis

Usage

server

# 1. install and start peerjs server
npm install -g peerjs
peerjs --port 8080 --host localhost

# 2. start proxy server
./bin/webrtc-proxy-server

client

interface WebrtcProxyClient {
    DialTcp(host: string, port: number): Promise<stream.Duplex>;
}
// for Node.js
const { client } = require("@zckevin/webrtc-proxy-conn/packages/node").WebrtcConn;

// for browser
const { client } = require("webrtc-proxy-conn/packages/browser");

client.DialTcp("localhost", 8080).then(duplex => {
    // ...
});

Testing

# start local peerjs websocket server
# because it's hard to spawn & kill peerjs server in tests,
# use we spawn it mannually
peerjs --port 8080 --host localhost

npm run test

Readme

Keywords

none

Package Sidebar

Install

npm i @zckevin/webrtc-proxy-conn

Weekly Downloads

0

Version

0.0.6

License

ISC

Unpacked Size

831 kB

Total Files

14

Last publish

Collaborators

  • zckevin