Home Reference Source
import Unicast from 'unicast-definition'
public class | source

Unicast

Extends:

events~EventEmitter → Unicast

Unicast component that simply sends messages to a neighbor. It provides easy-to-use event-like functions on top of a peer-sampling protocol. Protocols can send messages using unicast.emit('eventName', neighborId, args) and the neighbor can catch them using unicast.on('eventName', args).

Constructor Summary

Public Constructor
public

constructor(psp: IPSP, options: object)

Member Summary

Public Members
public

emit(event: string, peerId: string, args: object[]): Promise: *

Send a message using the emit function.

public

options: *

public

psp: *

Private Members
private

_emit: *

Method Summary

Public Methods
public

Destroy all listeners and remove the send capabilities

Public Constructors

public constructor(psp: IPSP, options: object) source

Params:

NameTypeAttributeDescription
psp IPSP

The peer-sampling protocol.

options object
  • optional

The options of this unicast.

options.pid string
  • optional
  • default: 'default-unicast'

The name of this unicast.

option.retry number
  • optional
  • default: 0

The number of attempt to send a message.

Public Members

public emit(event: string, peerId: string, args: object[]): Promise: * source

Send a message using the emit function.

Return:

Promise

Resolved if the message seems to have been sent, rejected otherwise (e.g. timeout, unkown peers).

public options: * source

public psp: * source

Private Members

private _emit: * source

Public Methods

public destroy() source

Destroy all listeners and remove the send capabilities