Home Reference Source
import IProtocol from 'neighborhood-wrtc'
public class | source

IProtocol

Extends:

lib/neighborhood.js~N → IProtocol

An interface for protocols that checks if all functions have been provided. Not fully necessary since it will only be checked at runtime anyway.

Method Summary

Private Methods
private

_connected(peerId: string, isOutgoing: boolean)

Behavior when an arc leading to peer has been established.

private

Behavior when an arc leading to peer has been disconnected.

private

_failed(peerId: string, isOutgoing: boolean)

Behavior when an arc failed to establish properly.

private

_received(peerId: string, message: object)

Behavior when a message from peerId has been received.

private

_streamed(peerId: string, stream: object)

Behavior when a stream from peerId is being received.

Private Methods

private _connected(peerId: string, isOutgoing: boolean) source

Behavior when an arc leading to peer has been established.

Params:

NameTypeAttributeDescription
peerId string
  • optional

The identifier of the peer reachable through the arc.

isOutgoing boolean
  • optional

State whether or not the added arc is an outgoing arc.

private _disconnected(peerId: string) source

Behavior when an arc leading to peer has been disconnected.

Params:

NameTypeAttributeDescription
peerId string
  • optional

The identifier of the peer reachable through the arc.

private _failed(peerId: string, isOutgoing: boolean) source

Behavior when an arc failed to establish properly.

Params:

NameTypeAttributeDescription
peerId string
  • optional

The identifier of the peer that we tried to establish a connection with.

isOutgoing boolean
  • optional

State whether or not the failed arc was supposed to be an outgoing arc.

private _received(peerId: string, message: object) source

Behavior when a message from peerId has been received.

Params:

NameTypeAttributeDescription
peerId string
  • optional

The identifier of the peer that sent the message.

message object
  • optional

The received message.

private _streamed(peerId: string, stream: object) source

Behavior when a stream from peerId is being received.

Params:

NameTypeAttributeDescription
peerId string
  • optional

The identifier of the peer that sent the message.

stream object
  • optional

The received stream.