@zckevin/webrtc-proxy-conn
v0.0.6
Published
`npm install --save @zckevin/webrtc-proxy-conn`
Downloads
1
Readme
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