Skip to main content

Class: Peer

protocol.protocol.Peer

Represents a Peer.

Implements

Constructors

constructor

new Peer(properties?): Peer

Constructs a new Peer.

Parameters

NameTypeDescription
properties?IPeerProperties to set

Returns

Peer

Properties

id

id: string

Peer id.

Implementation of

IPeer.id


metadata

metadata: string

Peer metadata.

Implementation of

IPeer.metadata


username

username: string

Peer username.

Implementation of

IPeer.username

Methods

create

create(properties?): Peer

Creates a new Peer instance using the specified properties.

Parameters

NameTypeDescription
properties?IPeerProperties to set

Returns

Peer

Peer instance


decode

decode(reader, length?): Peer

Decodes a Peer message from the specified reader or buffer.

Parameters

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from
length?numberMessage length if known beforehand

Returns

Peer

Peer

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


decodeDelimited

decodeDelimited(reader): Peer

Decodes a Peer message from the specified reader or buffer, length delimited.

Parameters

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from

Returns

Peer

Peer

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


encode

encode(message, writer?): Writer

Encodes the specified Peer message. Does not implicitly verify messages.

Parameters

NameTypeDescription
messageIPeerPeer message or plain object to encode
writer?WriterWriter to encode to

Returns

Writer

Writer


encodeDelimited

encodeDelimited(message, writer?): Writer

Encodes the specified Peer message, length delimited. Does not implicitly verify messages.

Parameters

NameTypeDescription
messageIPeerPeer message or plain object to encode
writer?WriterWriter to encode to

Returns

Writer

Writer


fromObject

fromObject(object): Peer

Creates a Peer message from a plain object. Also converts values to their respective internal types.

Parameters

NameTypeDescription
objectObjectPlain object

Returns

Peer

Peer


getTypeUrl

getTypeUrl(typeUrlPrefix?): string

Gets the default type url for Peer

Parameters

NameTypeDescription
typeUrlPrefix?stringyour custom typeUrlPrefix(default "type.googleapis.com")

Returns

string

The default type url


toJSON

toJSON(): Object

Converts this Peer to JSON.

Returns

Object

JSON object


toObject

toObject(message, options?): Object

Creates a plain object from a Peer message. Also converts values to other types if specified.

Parameters

NameTypeDescription
messagePeerPeer
options?IConversionOptionsConversion options

Returns

Object

Plain object


verify

verify(message): string

Verifies a Peer message.

Parameters

NameTypeDescription
messageObjectPlain object to verify

Returns

string

null if valid, otherwise the reason why it is not