unicast-definition
Keywords: Unicast, browser-to-browser communication, WebRTC
Unicast component relying on a n2n component. Similarly to socket.io, this module provides an event-like API to send and receive messages.
Installation
npm install unicast-definition
API
The API is available here.
Usage
// require as you want the N2N moduleconst S = // require this moduleconst U = // #1 create 3 peersconst s1 = peer: '1' config: trickle: trueconst s2 = peer: '2' config: trickle: trueconst s3 = peer: '3' config: trickle: true// #2 associate a unicast protocol to each peerconst u1 = s1 retry: 1 pid: 'com1'const u2 = s2 retry: 1 pid: 'com1'const u3 = s3 retry: 1 pid: 'com1' u1u2u3 const u4 = s1 retry: 1 pid: 'com2'const u5 = s2 retry: 1 pid: 'com2'const u6 = s3 retry: 1 pid: 'com2' u4u5u6 // #4 simulate signaling serverconst callback = { return { to }} // #4 s1 contacts s2, 2-peers networks1