socket.io-bridge-client

Real-time bidirectional event-based communication between two socket.io clients

Usage no npm install needed!

<script type="module">
  import socketIoBridgeClient from 'https://cdn.skypack.dev/socket.io-bridge-client';
</script>

README

socket.io-bridge-client

Client implementation for socket.io-bridge.

Please find the project documentation at https://github.com/michaelfranzl/socket.io-bridge .

API Reference

Classes

BridgeClient

Typedefs

Socket

BridgeClient

Kind: global class

new BridgeClient(opts)

Param Type
opts Object
opts.socket Socket

BridgeClient.make(opts) ⇒ Promise

Make a Socket.IO bridge to another client.

Kind: static method of BridgeClient
Returns: Promise - - Promise resolving with a Socket.IO client socket connecting to the requested peer/client. The Promise can be used only for a single connection, e.g. when peerUid is set and there will be no incoming connections.

Param Type Default Description
opts Object
[opts.uid] string "globally unique" Our ID.
[opts.peerUid] string The ID of the peer we want to establish a connection to.
[opts.onconnection] onconnection Called for each incoming connection.
[opts.logger] object No logging by default

BridgeClient~onconnection : function

Called as soon as the peer identified by peerUid is available for a connection.

Kind: inner typedef of BridgeClient

Param Type Description
socket Socket Socket.IO client socket connecting to the requested peer/client.

Socket

Kind: global typedef
See: https://github.com/socketio/socket.io-client/blob/master/docs/API.md#socket