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 aRequest. - 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
Domainenum comes from the Contracts system, and theParamsclass from the Params system. ARequestis aMessage, and carries its data as typed params. - The request system is reached through
BusRegistry, which holds theRequestDispatcher, and throughBusUtility, which forwards requests to it. Both are looked up withServiceLocator. - Routing is handled by the
MessageBusbase class, which the internalRequestBusextends.