Class ServiceDispatcher
java.lang.Object
br.net.dd.netherwingcore.bnetserver.services.ServiceDispatcher
The ServiceDispatcher is responsible for routing incoming RPC calls to the appropriate service based on the service hash.
It maintains a mapping of service hashes to ServiceMethod instances, which are functional interfaces that call the appropriate
method on the service. When a call is dispatched, it looks up the service method using the service hash and invokes it with
the session, token, method ID, and packet buffer.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddispatch(Session session, int serviceHash, int token, int methodId, MessageBuffer buffer) Dispatches an incoming RPC call to the appropriate service based on the service hash.static ServiceDispatcherReturns the singleton instance of the ServiceDispatcher.
-
Method Details
-
getInstance
Returns the singleton instance of the ServiceDispatcher.- Returns:
- the singleton instance of the ServiceDispatcher
-
dispatch
public void dispatch(Session session, int serviceHash, int token, int methodId, MessageBuffer buffer) Dispatches an incoming RPC call to the appropriate service based on the service hash. It takes the session from which the call originated, the authentication token associated with the call, the method ID of the method being called, and the buffer containing the serialized request data. It looks up the service method using the service hash and invokes it with the session, token, method ID, and packet buffer. If no service is found for the given service hash, it logs an error message.- Parameters:
session- the session from which the call originatedserviceHash- the unique hash of the service being calledtoken- the authentication token associated with the callmethodId- the ID of the method being calledbuffer- the buffer containing the serialized request data
-