Class ProtobufSerializer

Hierarchy

  • DataSerializer
    • ProtobufSerializer

Constructors

Properties

deserializer: Deserializer
eventEmitter: EventEmitter<DefaultEventMap>
knownTypes: Map<string, Serializable<any>>
root: Root
serializer: Serializer
wrapperMessage: Type

Methods

  • Clone a serializable object

    Type Parameters

    • T
    • D = T

    Parameters

    • object: T

      Serializable object

    • Optional dataType: Constructor<D>

      Data type to clone to

    Returns D

    Cloned object

  • Deserialize data

    Type Parameters

    • T

    Parameters

    • serializedData: any

      Data to deserialze

    • Optional dataType: Constructor<T>

      Optional data type to specify deserialization type

    • Optional config: DataSerializerConfig

      Data serializer configuration

    Returns T

  • Find the root TypedJSON metadata

    Parameters

    • proto: any

      Prototype of target

    Returns ObjectMetadata

    Root object metadata

    Deprecated

    use DataSerializerUtils.getRootMetadata

  • Parameters

    • name: string

    Returns Serializable<any>

  • Get the TypedJSON metadata

    Parameters

    • proto: any

      Prototype of target

    Returns ObjectMetadata

    Root object metadata

    Deprecated

    use DataSerializerUtils.getMetadata

    See

    https://gist.github.com/krizka/c83fb1966dd57997a1fc02625719387d

  • Get the root TypedJSON metadata

    Parameters

    • proto: any

      Prototype of target

    Returns ObjectMetadata

    Root object metadata

    Deprecated

    use DataSerializerUtils.getRootMetadata

    See

    https://gist.github.com/krizka/c83fb1966dd57997a1fc02625719387d

  • Initialize the protocol buffer serializer

    Parameters

    • Optional directory: string

      Directory of generated protocol messages. Default will generate on the fly

    Returns Promise<void>

    Promise once initialized

  • Manually register a new type

    Type Parameters

    • T

    Parameters

    • type: Serializable<T>

      Type to register

    • Optional converters: MappedTypeConverters<T>

      Optional converters

    Returns void

  • Serialize data

    Type Parameters

    • T

    Parameters

    • data: T

      Data to serialize

    • Optional config: DataSerializerConfig

      Data serializer configuration

    Returns Uint8Array

    Serialized buffer

  • Unregister a type

    Parameters

    • type: Serializable<any>

      Type to unregister

    Returns void