java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.DefaultRPCProvider
eu.cloudnetservice.driver.network.rpc.defaults.sender.DefaultRPCSender
All Implemented Interfaces:
RPCProvider, RPCSender

public class DefaultRPCSender extends DefaultRPCProvider implements RPCSender
The default implementation of a rpc sender.
Since:
4.0
  • Field Details

    • EMPTY_OBJECT_ARRAY

      protected static final Object[] EMPTY_OBJECT_ARRAY
    • targetClass

      protected final Class<?> targetClass
    • factory

      protected final RPCFactory factory
    • networkComponent

      protected final NetworkComponent networkComponent
    • cachedMethodInformation

      protected final com.github.benmanes.caffeine.cache.Cache<String,MethodInformation> cachedMethodInformation
  • Constructor Details

  • Method Details

    • factory

      @NonNull public @NonNull RPCFactory factory()
      Get the provider factory used to construct this rpc sender.
      Specified by:
      factory in interface RPCSender
      Returns:
      the provider factory used to construct this rpc sender.
    • associatedComponent

      @NonNull public @NonNull NetworkComponent associatedComponent()
      Get the network component associated with this rpc sender.
      Specified by:
      associatedComponent in interface RPCSender
      Returns:
      the network component associated with this rpc sender.
    • invokeMethod

      @NonNull public @NonNull RPC invokeMethod(@NonNull @NonNull String methodName)
      Creates a rpc to invoke the target method with no arguments, preventing a new object array allocation each time the method is invoked. Equivalent to sender.invokeMethod(name, new Object[0]).
      Specified by:
      invokeMethod in interface RPCSender
      Parameters:
      methodName - the name of the method to invoke.
      Returns:
      the rpc usable to fire the rpc request against the given method.
    • invokeMethod

      @NonNull public @NonNull RPC invokeMethod(@NonNull @NonNull String methodName, Object... args)
      Creates a rpc to invoke the target method with the given arguments. For this operation to succeed, the class must
      1. contain a method which equals the given method name (case sensitive)
      2. that method must have the amount of arguments supplied via the arguments array.
      Specified by:
      invokeMethod in interface RPCSender
      Parameters:
      methodName - the name of the method to invoke.
      args - the arguments to use for the method invocation.
      Returns:
      the rpc usable to fire the rpc request against the given method.