@rbxts/fletchette
    Preparing search index...

    Class RequestPacket<V, B, T>

    A request packet that can be sent between client and server. This packet can be used to send data to the server and receive a response, or toClient a client for a response.

    Type Parameters

    • V

      The data being sent by the request

    • B

      The data being received by the request

    • T extends (...args: Parameters<V>) => B

      The function signature for the request

    Hierarchy (View Summary)

    Index

    Constructors

    • Create a RequestPacket with a unique id. Metadata can be provided to specify how the data should be serialized.

      Type Parameters

      • V
      • B
      • T extends (...args: Parameters<V>) => B

      Parameters

      • id: string

        Unique identifier for the request

      • Optionalmeta: Many<SerializerMetadata<Parameters<T>>>

        Metadata for serialization

      Returns RequestPacket<V, B, T>

    Properties

    className: "RequestPacket"

    Class name of the packet, used for debugging purposes.

    id: string

    Unique identifier for the request

    remoteFunction: RemoteFunction

    RemoteFunction used to send the request

    serializer: Serializer<Parameters<T>>

    Serializer for the data being sent by the request

    virtualClientHandler?: (...args: Parameters<T>) => B

    Virtual handler that can be used to handle the request on the client

    virtualServerHandler?: (player: Player, ...args: Parameters<T>) => B

    Virtual handler that can be used to handle the request on the server

    Methods

    • Set up a handler for the server to respond to toServer. This function should only be called on the server to listen for requests made by the client.

      Parameters

      • handler: (player: Player, ...args: Parameters<T>) => B

        The handler to call when a request is made

      Returns void

    • Set up a handler for the client to respond to toClient. This function should only be called on the client to listen for queries made by the server.

      Parameters

      • handler: (...args: Parameters<T>) => B

        The handler to call when a toClient is made

      Returns void

    • Query a client for a response. The client should have a handler set up with fromServer that can handle the toClient. Hence, this function should only be called on the server.

      Parameters

      • player: Player

        The player to send the toClient to

      • ...args: Parameters<T>

        The data to send

      Returns B

    • Invoke the request on the server. The server should have a handler set up with fromClient that can handle the toServer. Hence, this function should only be called on the client.

      Parameters

      • ...args: Parameters<T>

        The data to send

      Returns B