Abstract peer to peer transport API for client and server.
Permit to create a fully connected peer to peer network based on WebRTC and WebSocket.
Allows to send/receive the following data types over the network: String, ArrayBuffer, TypedArray.
Table of contents
Full documentation: https://doc.esdoc.org/github.com/coast-team/netflux
create function is the start point, unless you are developing a peer bot, then consider using
BotServer (see below).
create functions return an object of type
WebChannel which represents the peer to peer network.
dist/netflux.es5.umd.minjs both exports:
- id: number
- members: number
- myId: number**
- onMessage: function (peerId: number, msg: UserMessage, isBroadcast: boolean)**
- onPeerJoin: function (peerId: number)
- onPeerLeave: function (peerId: number)**
- onClose: function (closeEvt: CloseEvent)**
Open method allows other peers to join your network.
- open([options: OpenData]): Promise<OpenData, string>
- getOpenData(): OpenData | null
- isOpen(): boolean
After someone has opened his network and has provided the key to you, you can join his network.
Any member can invite a peer bot (server) to join this network.
Any member is allowed to send a message.
- WEB_RTC constant
- WEB_SOCKET constant