Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PacketIO

A utility class which implements the RotMG messaging protocol on top of a Socket.

Hierarchy

  • EventEmitter
    • PacketIO

Index

Constructors

constructor

  • Creates a new PacketIO on top of the given socket.

    Parameters

    • Optional socket: Socket

      The socket to implement the protocol on top of.

    • Default value rc4Config: RC4Config = DEFAULT_RC4

    Returns PacketIO

Properties

Private _lastIncomingPacket

_lastIncomingPacket: Packet

Private _lastOutgoingPacket

_lastOutgoingPacket: Packet

Private eventHandlers

eventHandlers: Map<string, function>

Private outgoingBuffer

outgoingBuffer: PacketBuffer

Private packetBuffer

packetBuffer: PacketBuffer

Private receiveRC4

receiveRC4: RC4

Private sendRC4

sendRC4: RC4

socket

socket: Socket

The socket this packet interface is attached to.

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

lastIncomingPacket

  • get lastIncomingPacket(): Packet

lastOutgoingPacket

  • get lastOutgoingPacket(): Packet

Methods

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

attach

  • attach(socket: Socket): void
  • Attaches this Packet IO to the socket.

    Parameters

    • socket: Socket

      The socket to attach to.

    Returns void

Private checkBuffer

  • checkBuffer(): void

Private constructPacket

detach

  • detach(): void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

Private emitError

  • emitError(error: Error): void

emitPacket

  • emitPacket(packet: Packet): void
  • Emits a packet from this PacketIO instance. This will only emit the packet to the clients subscribed to this particular PacketIO.

    Parameters

    • packet: Packet

      The packet to emit.

    Returns void

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Private onConnect

  • onConnect(): void

Private onData

  • onData(data: Buffer): void

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Private resetBuffer

  • resetBuffer(): void

send

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc