Class ServiceDispatcher

java.lang.Object
br.net.dd.netherwingcore.bnetserver.services.ServiceDispatcher

public class ServiceDispatcher extends Object
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 Details

    • getInstance

      public static ServiceDispatcher 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 originated
      serviceHash - the unique hash of the service being called
      token - the authentication token associated with the call
      methodId - the ID of the method being called
      buffer - the buffer containing the serialized request data