Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Protobuf

Hierarchy

  • Protobuf

Index

Constructors

constructor

  • Parameters

    • opts: object
      • decoderProtos: object
      • encoderProtos: object

    Returns Protobuf

Properties

decoder

decoder: Decoder

encoder

encoder: Encoder

Methods

decode

  • decode(key: string, msg: Buffer): object
  • Parameters

    • key: string
    • msg: Buffer

    Returns object

    • [key: string]: any

decodeStr

  • decodeStr(key: string, str: string, code: string): object
  • Parameters

    • key: string
    • str: string
    • code: string

    Returns object

    • [key: string]: any

encode

  • encode(key: string, msg: object): Buffer
  • [encode the given message, return a Buffer represent the message encoded by protobuf]

    Parameters

    • key: string

      The key to identify the message type.

    • msg: object

      The message body, a js object.

    Returns Buffer

    The binary encode result in a Buffer.

encode2Bytes

  • encode2Bytes(key: string, msg: object): Uint8Array
  • Parameters

    • key: string
    • msg: object

    Returns Uint8Array

encodeStr

  • encodeStr(key: string, msg: object, code: string): string | Buffer
  • Parameters

    • key: string
    • msg: object
    • code: string

    Returns string | Buffer

setDecoderProtos

  • setDecoderProtos(protos: object): void

setEncoderProtos

  • setEncoderProtos(protos: object): void

Static parse

  • parse(json: object): object
  • Parameters

    • json: object

    Returns object

    • [key: string]: any