Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PacketDecoder<ContextType>

Type parameters

  • ContextType

Hierarchy

  • PacketDecoder

Index

Methods

clear

  • clear(): void

emit

emitDecoded

  • Emit a decoded message to all listeners concurrently, also emits the message's children recursively.

    Parameters

    • message: Serializable

      The message to emit.

    • direction: MessageDirection

      The direction that the message was sent.

    • context: ContextType

      Additional metadata for the message, e.g. the context.

    Returns Promise<void>

emitDecodedSerial

  • Emit a decoded message to all listeners serially, also emits the message's children recursively.

    Parameters

    • message: Serializable

      The message to emit.

    • direction: MessageDirection

      The direction that the message was sent.

    • context: ContextType

      Additional metadata for the message, e.g. the context.

    Returns Promise<void>

emitSerial

getListeners

off

on

  • Listen to a message being sent through the decoder.

    Type parameters

    Parameters

    • messageClass: T

      The message to listen for.

    • listener: MessageListener<GetSerialized<T>, ContextType>

      The callback for when the message is decoded.

    Returns () => void

    A function to remove the listener.

      • (): void
      • Listen to a message being sent through the decoder.

        Returns void

        A function to remove the listener.

  • Listen to any of several messages being sent through the decoder.

    Type parameters

    Parameters

    • messageClass: T

      The messages to listen for.

    • listener: MessageListener<GetSerialized<T[number]>, ContextType>

      The callback for when one of the messages is decoded.

    Returns () => void

    A function to remove the listener.

      • (): void
      • Listen to any of several messages being sent through the decoder.

        Returns void

        A function to remove the listener.

once

  • Listen to a message being sent through the decoder once.

    Type parameters

    Parameters

    • messageClass: T

      The message to listen for.

    • listener: MessageListener<GetSerialized<T>, ContextType>

      The callback for when the message is decoded.

    Returns () => void

    A function to remove the listener.

      • (): void
      • Listen to a message being sent through the decoder once.

        Returns void

        A function to remove the listener.

  • Listen to any of several messages being sent through the decoder once.

    Type parameters

    Parameters

    • messageClass: T

      The messages to listen for.

    • listener: MessageListener<GetSerialized<T[number]>, ContextType>

      The callback for when one of the messages is decoded.

    Returns () => void

    A function to remove the listener.

      • (): void
      • Listen to any of several messages being sent through the decoder once.

        Returns void

        A function to remove the listener.

parse

register

reset

  • reset(): void

wait

waitf

write

Properties

config

config: PacketDecoderConfig

listeners

listeners: Map<`${string}:${number}`, MessageListener<Serializable, ContextType>[]>

types

types: Map<`${string}:${number}`, Deserializable>

Constructors

constructor

  • new PacketDecoder<ContextType>(config?: Partial<PacketDecoderConfig>): PacketDecoder<ContextType>

Generated using TypeDoc