Skip to main content

Class: Message

protocol.protocol.Message

Represents a Message.

Implements

Constructors

constructor

new Message(properties?): Message

Constructs a new Message.

Parameters

NameTypeDescription
properties?IMessageProperties to set

Returns

Message

Properties

chat

Optional chat: IChatMessage

Message chat.

Implementation of

IMessage.chat


chunks

chunks: IChunk[]

Message chunks.

Implementation of

IMessage.chunks


entities

entities: IEntity[]

Message entities.

Implementation of

IMessage.entities


events

events: IEvent[]

Message events.

Implementation of

IMessage.events


json

json: string

Message json.

Implementation of

IMessage.json


method

Optional method: IMethod

Message method.

Implementation of

IMessage.method


peers

peers: IPeer[]

Message peers.

Implementation of

IMessage.peers


text

text: string

Message text.

Implementation of

IMessage.text


type

type: Type

Message type.

Implementation of

IMessage.type


updates

updates: IUpdate[]

Message updates.

Implementation of

IMessage.updates

Methods

create

create(properties?): Message

Creates a new Message instance using the specified properties.

Parameters

NameTypeDescription
properties?IMessageProperties to set

Returns

Message

Message instance


decode

decode(reader, length?): Message

Decodes a Message message from the specified reader or buffer.

Parameters

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

Returns

Message

Message

Throws

If the payload is not a reader or valid buffer

Throws

If required fields are missing


decodeDelimited

decodeDelimited(reader): Message

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

Parameters

NameTypeDescription
readerUint8Array | ReaderReader or buffer to decode from

Returns

Message

Message

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 Message message. Does not implicitly verify messages.

Parameters

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

Returns

Writer

Writer


encodeDelimited

encodeDelimited(message, writer?): Writer

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

Parameters

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

Returns

Writer

Writer


fromObject

fromObject(object): Message

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

Parameters

NameTypeDescription
objectObjectPlain object

Returns

Message

Message


getTypeUrl

getTypeUrl(typeUrlPrefix?): string

Gets the default type url for Message

Parameters

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

Returns

string

The default type url


toJSON

toJSON(): Object

Converts this Message to JSON.

Returns

Object

JSON object


toObject

toObject(message, options?): Object

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

Parameters

NameTypeDescription
messageMessageMessage
options?IConversionOptionsConversion options

Returns

Object

Plain object


verify

verify(message): string

Verifies a Message message.

Parameters

NameTypeDescription
messageObjectPlain object to verify

Returns

string

null if valid, otherwise the reason why it is not