Home Reference Source
import PartialView from 'tman-wrtc/lib/partialview.js'
public class | source

PartialView

Extends:

Map → PartialView

Structure containing the neighborhood of a peer. Each neigbhor entry comprises a list of ages and a descriptor. Map of {idPeer => {ages:[age_1, age_2.. age_k], descriptor: {x: exampleX} }} where age_1 <= age_2 <= .. <= age_k.

Member Summary

Public Members
public get

Get the least frequent peer.

public get

Get the oldest peer in the partial view.

Method Summary

Public Methods
public

addNeighbor(peerId: string, descriptor: object)

Add the peer to the partial view with an age of 0.

public

Get the descriptor of the peer in argument.

public

Increment the age of the whole partial view

public

Remove all entries of the peer from the partial view.

public

removeOldest(peerId: string)

Remove the newest entry of the peer from the partial view.

public

updateNeighbor(peerId: string, descriptor: object)

Update the peer's descriptor.

Public Members

public get leastFrequent: string: * source

Get the least frequent peer. If multiple peers have the same number of occurrences, it chooses one among them at random.

Return:

string

The identifier of a least frequent peer.

public get oldest: string: * source

Get the oldest peer in the partial view.

Return:

string

The oldest peer in the structure.

Public Methods

public addNeighbor(peerId: string, descriptor: object) source

Add the peer to the partial view with an age of 0.

Params:

NameTypeAttributeDescription
peerId string

The identifier of the peer added to the partial view.

descriptor object
  • optional
  • default: {}

The descriptor of the peer.

public getDescriptor(peerId: string): object source

Get the descriptor of the peer in argument.

Params:

NameTypeAttributeDescription
peerId string

The identifier of the peer.

Return:

object

The descriptor of the peer.

public increment() source

Increment the age of the whole partial view

public removeAllNeighbor(peerId: string): number source

Remove all entries of the peer from the partial view.

Params:

NameTypeAttributeDescription
peerId string

The identifier of the peer to remove from the partial view.

Return:

number

The number of occurrences of peerId removed.

public removeOldest(peerId: string) source

Remove the newest entry of the peer from the partial view.

Params:

NameTypeAttributeDescription
peerId string

The identifier of the peer to remove from the partial view.

public updateNeighbor(peerId: string, descriptor: object) source

Update the peer's descriptor.

Params:

NameTypeAttributeDescription
peerId string

The identifier of the peer to update.

descriptor object
  • optional
  • default: {}

The new descriptor of peerId.