docs
Systems
Messaging
RequestSystem
RequestSystem Overview

The RequestSystem lets one system ask another system, identified by a Domain, to do something on its behalf. The receiving system accepts or rejects the request and sends back a Response, which is delivered to the sender's callback.

Purpose in SaffronLibrary

The RequestSystem is part of the messaging layer in _Core/Messaging. It sits alongside the command, query, event, and signal buses. Unlike a command, a request is expected to receive a reply that tells the sender whether it was accepted or rejected, and why.

Key responsibilities

  • Carry the target Domain, a verb, a payload message, and an optional response callback in a Request.
  • Route each request to the handler registered for its target domain, queuing it until a handler exists.
  • Track each sent request by ID until its response arrives, then match the response back and invoke the sender's callback.

Who should use it

  • Gameplay and feature developers who need another system to perform an action and want to know the outcome.
  • Developers who own a domain and need to accept or reject requests for it by implementing a handler and replying through the RequestDispatcher.

Connections to other systems

  • The Domain enum comes from the Contracts system, and the Params class from the Params system. A Request is a Message, and carries its data as typed params.
  • The request system is reached through BusRegistry, which holds the RequestDispatcher, and through BusUtility, which forwards requests to it. Both are looked up with ServiceLocator.
  • Routing is handled by the MessageBus base class, which the internal RequestBus extends.