Constructor
new Message(values, …var_args)
Constructs a new runtime Message.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
values |
!Object.<string, *> | string | Preset values |
|
var_args |
string |
<repeatable> |
- Source:
Throws:
-
If the message cannot be created
- Type
- Error
Members
(static) $options :Object.<string, *>
Message options.
Type:
- Object.<string, *>
- Source:
(static, non-null) $type :ProtoBuf.Reflect.Message
Reflection type.
Type:
- Source:
$options :Object.<string, *>
Message options.
Type:
- Object.<string, *>
- Source:
(non-null) $type :ProtoBuf.Reflect.Message
Reflection type.
Type:
- Source:
Methods
(static) decode(buffer, lengthopt, encopt) → (non-null) {ProtoBuf.Builder.Message}
Decodes a message from the specified buffer or string.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
buffer |
ByteBuffer | ArrayBuffer | Buffer | string | Buffer to decode from |
|
length |
number | string |
<optional> |
Message length. Defaults to decode all the remainig data. |
enc |
string |
<optional> |
Encoding if buffer is a string: hex, utf8 (not recommended), defaults to base64 |
- Source:
- See:
Throws:
-
If the message cannot be decoded or if required fields are missing. The later still returns the decoded message with missing fields in the
decoded
property on the error. - Type
- Error
Returns:
Decoded message
(static) decode64(str) → (non-null) {ProtoBuf.Builder.Message}
Decodes the message from the specified base64 encoded string.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | String to decode from |
- Source:
Throws:
-
If the message cannot be decoded or if required fields are missing. The later still returns the decoded message with missing fields in the
decoded
property on the error. - Type
- Error
Returns:
Decoded message
(static) decodeDelimited(buffer, encopt) → {ProtoBuf.Builder.Message}
Decodes a varint32 length-delimited message from the specified buffer or string.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
buffer |
ByteBuffer | ArrayBuffer | Buffer | string | Buffer to decode from |
|
enc |
string |
<optional> |
Encoding if buffer is a string: hex, utf8 (not recommended), defaults to base64 |
- Source:
Throws:
-
If the message cannot be decoded or if required fields are missing. The later still returns the decoded message with missing fields in the
decoded
property on the error. - Type
- Error
Returns:
Decoded message or null
if not enough bytes are available yet
(static) decodeHex(str) → (non-null) {ProtoBuf.Builder.Message}
Decodes the message from the specified hex encoded string.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | String to decode from |
- Source:
Throws:
-
If the message cannot be decoded or if required fields are missing. The later still returns the decoded message with missing fields in the
decoded
property on the error. - Type
- Error
Returns:
Decoded message
(static) decodeJSON(str) → (non-null) {ProtoBuf.Builder.Message}
Decodes the message from a JSON string.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | String to decode from |
- Source:
Throws:
-
If the message cannot be decoded or if required fields are missing.
- Type
- Error
Returns:
Decoded message
$add(key, value, noAssertopt) → (non-null) {ProtoBuf.Builder.Message}
Adds a value to a repeated field. This is an alias for ProtoBuf.Builder.Message#add.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string | Field name |
|
value |
* | Value to add |
|
noAssert |
boolean |
<optional> |
Whether to assert the value or not (asserts by default) |
- Source:
Throws:
-
If the value cannot be added
- Type
- Error
Returns:
this
$encode(bufferopt, noVerifyopt) → (non-null) {ByteBuffer}
Encodes the message.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
buffer |
ByteBuffer | boolean |
<optional> |
ByteBuffer to encode to. Will create a new one and flip it if omitted. |
noVerify |
boolean |
<optional> |
Whether to not verify field values, defaults to |
- Source:
- See:
Throws:
-
If the message cannot be encoded or if required fields are missing. The later still returns the encoded ByteBuffer in the
encoded
property on the error. - Type
- Error
Returns:
Encoded message as a ByteBuffer
- Type
- ByteBuffer
$get(key) → {*}
Gets a field's value. This is an alias for ProtoBuf.Builder.Message#$get.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Key |
- Source:
Throws:
-
If there is no such field
- Type
- Error
Returns:
Value
- Type
- *
$set(keyOrObj, valueopt, noAssertopt)
Sets a field's value. This is an alias for [@link ProtoBuf.Builder.Message#set}.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keyOrObj |
string | !Object.<string, *> | String key or plain object holding multiple values |
|
value |
* | boolean |
<optional> |
Value to set if key is a string, otherwise omitted |
noAssert |
boolean |
<optional> |
Whether to not assert the value, defaults to |
- Source:
Throws:
-
If the value cannot be set
- Type
- Error
add(key, value, noAssertopt) → (non-null) {ProtoBuf.Builder.Message}
Adds a value to a repeated field.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string | Field name |
|
value |
* | Value to add |
|
noAssert |
boolean |
<optional> |
Whether to assert the value or not (asserts by default) |
- Source:
Throws:
-
If the value cannot be added
- Type
- Error
Returns:
this
calculate() → {number}
Calculates the byte length of the message.
- Source:
Throws:
-
If the message cannot be calculated or if required fields are missing.
- Type
- Error
Returns:
Byte length
- Type
- number
encode64() → {string}
Directly encodes the message to a base64 encoded string.
- Source:
Throws:
-
If the underlying buffer cannot be encoded or if required fields are missing. The later still returns the encoded base64 string in the
encoded
property on the error. - Type
- Error
Returns:
Base64 encoded string
- Type
- string
encodeAB() → {ArrayBuffer}
Directly encodes the message to an ArrayBuffer.
- Source:
Throws:
-
If the message cannot be encoded or if required fields are missing. The later still returns the encoded ArrayBuffer in the
encoded
property on the error. - Type
- Error
Returns:
Encoded message as ArrayBuffer
- Type
- ArrayBuffer
encodeDelimited(bufferopt, noVerifyopt) → (non-null) {ByteBuffer}
Encodes the varint32 length-delimited message.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
buffer |
ByteBuffer | boolean |
<optional> |
ByteBuffer to encode to. Will create a new one and flip it if omitted. |
noVerify |
boolean |
<optional> |
Whether to not verify field values, defaults to |
- Source:
Throws:
-
If the message cannot be encoded or if required fields are missing. The later still returns the encoded ByteBuffer in the
encoded
property on the error. - Type
- Error
Returns:
Encoded message as a ByteBuffer
- Type
- ByteBuffer
encodeHex() → {string}
Directly encodes the message to a hex encoded string.
- Source:
Throws:
-
If the underlying buffer cannot be encoded or if required fields are missing. The later still returns the encoded hex string in the
encoded
property on the error. - Type
- Error
Returns:
Hex encoded string
- Type
- string
encodeJSON() → {string}
Encodes a message to JSON.
- Source:
Returns:
JSON string
- Type
- string
encodeNB() → (non-null) {Buffer}
Directly encodes the message to a node Buffer.
- Source:
Throws:
-
If the message cannot be encoded, not running under node.js or if required fields are missing. The later still returns the encoded node Buffer in the
encoded
property on the error. - Type
- Error
Returns:
- Type
- Buffer
get(key, noAssertopt) → {*}
Gets a field's value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string | Key |
|
noAssert |
boolean |
<optional> |
Whether to not assert for an actual field, defaults to |
- Source:
Throws:
-
If there is no such field
- Type
- Error
Returns:
Value
- Type
- *
(abstract) get[SomeField]() → {*}
Gets a value. This method is present for each field, but only if there is no name conflict with another field.
- Source:
Returns:
The value
- Type
- *
(abstract) get_[some_field]() → {*}
Gets a value. This method is present for each field, but only if there is no name conflict with another field.
- Source:
Returns:
The value
- Type
- *
set(keyOrObj, valueopt, noAssertopt) → (non-null) {ProtoBuf.Builder.Message}
Sets a field's value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keyOrObj |
string | !Object.<string, *> | String key or plain object holding multiple values |
|
value |
* | boolean |
<optional> |
Value to set if key is a string, otherwise omitted |
noAssert |
boolean |
<optional> |
Whether to not assert for an actual field / proper value type, defaults to |
- Source:
Throws:
-
If the value cannot be set
- Type
- Error
Returns:
this
(abstract) set[SomeField](value, noAssertopt) → (non-null) {ProtoBuf.Builder.Message}
Sets a value. This method is present for each field, but only if there is no name conflict with another field.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
* | Value to set |
|
noAssert |
boolean |
<optional> |
Whether to not assert the value, defaults to |
- Source:
Throws:
-
If the value cannot be set
- Type
- Error
Returns:
this
(abstract) set_[some_field](value, noAssertopt) → (non-null) {ProtoBuf.Builder.Message}
Sets a value. This method is present for each field, but only if there is no name conflict with another field.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
* | Value to set |
|
noAssert |
boolean |
<optional> |
Whether to not assert the value, defaults to |
- Source:
Throws:
-
If the value cannot be set
- Type
- Error
Returns:
this
toArrayBuffer() → {ArrayBuffer}
Returns the message as an ArrayBuffer. This is an alias for ProtoBuf.Builder.Message#encodeAB.
- Source:
Throws:
-
If the message cannot be encoded or if required fields are missing. The later still returns the encoded ArrayBuffer in the
encoded
property on the error. - Type
- Error
Returns:
Encoded message as ArrayBuffer
- Type
- ArrayBuffer
toBase64() → {string}
Returns the message as a base64 encoded string. This is an alias for ProtoBuf.Builder.Message#encode64.
- Source:
Throws:
-
If the message cannot be encoded or if required fields are missing. The later still returns the encoded base64 string in the
encoded
property on the error. - Type
- Error
Returns:
Base64 encoded string
- Type
- string
toBuffer() → (non-null) {Buffer}
Returns the message as a node Buffer. This is an alias for ProtoBuf.Builder.Message#encodeNB.
- Source:
Throws:
-
If the message cannot be encoded or if required fields are missing. The later still returns the encoded node Buffer in the
encoded
property on the error. - Type
- Error
Returns:
- Type
- Buffer
toHex() → {string}
Returns the message as a hex encoded string. This is an alias for ProtoBuf.Builder.Message#encodeHex.
- Source:
Throws:
-
If the message cannot be encoded or if required fields are missing. The later still returns the encoded hex string in the
encoded
property on the error. - Type
- Error
Returns:
Hex encoded string
- Type
- string
toRaw(binaryAsBase64opt, longsAsStrings) → {Object.<string, *>}
Returns the message's raw payload.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
binaryAsBase64 |
boolean |
<optional> |
Whether to include binary data as base64 strings instead of Buffers, defaults to |
longsAsStrings |
boolean | Whether to encode longs as strings |
- Source:
Returns:
Raw payload
- Type
- Object.<string, *>
toString() → {string}
Returns a string representation of this Message.
- Source:
Returns:
String representation as of ".Fully.Qualified.MessageName"
- Type
- string