Class CallbackManager

  • All Implemented Interfaces:
    ICallbackMgrInternals

    public class CallbackManager
    extends java.lang.Object
    implements ICallbackMgrInternals
    This class is a utility for routing callbacks to function calls. In order to bind callbacks to functions, an instance of this class must be created for the SteamClient instance that will be posting callbacks.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void register​(in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackBase callback)  
      void runCallbacks()
      Runs a single queued callback.
      void runWaitAllCallbacks​(int timeout)
      Blocks the current thread to run all queued callbacks.
      void runWaitCallbacks()
      Blocks the current thread to run a single queued callback.
      void runWaitCallbacks​(long timeout)
      Blocks the current thread to run a single queued callback.
      <TCallback extends ICallbackMsg>
      java.io.Closeable
      subscribe​(java.lang.Class<? extends TCallback> callbackType, JobID jobID, Consumer<TCallback> callbackFunc)
      REgisters the provided Consumer to receive callbacks of type CallbackManager
      <TCallback extends ICallbackMsg>
      java.io.Closeable
      subscribe​(java.lang.Class<? extends TCallback> callbackType, Consumer<TCallback> callbackFunc)
      REgisters the provided Consumer to receive callbacks of type CallbackManager
      void unregister​(in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackBase callback)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CallbackManager

        public CallbackManager​(SteamClient steamClient)
        Initializes a new instance of the CallbackManager class.
        Parameters:
        steamClient - The SteamClient instance to handle the callbacks of.
    • Method Detail

      • runCallbacks

        public void runCallbacks()
        Runs a single queued callback. If no callback is queued, this method will instantly return.
      • runWaitCallbacks

        public void runWaitCallbacks​(long timeout)
        Blocks the current thread to run a single queued callback. If no callback is queued, the method will block for the given timeout.
        Parameters:
        timeout - The length of time to block.
      • runWaitCallbacks

        public void runWaitCallbacks()
        Blocks the current thread to run a single queued callback. If no callback is queued, the method will block until one is posted.
      • runWaitAllCallbacks

        public void runWaitAllCallbacks​(int timeout)
        Blocks the current thread to run all queued callbacks. If no callback is queued, the method will block for the given timeout.
        Parameters:
        timeout - The length of time to block.
      • subscribe

        public <TCallback extends ICallbackMsg> java.io.Closeable subscribe​(java.lang.Class<? extends TCallback> callbackType,
                                                                            JobID jobID,
                                                                            Consumer<TCallback> callbackFunc)
        REgisters the provided Consumer to receive callbacks of type CallbackManager
        Type Parameters:
        TCallback - The type of callback to subscribe to.
        Parameters:
        callbackType - type of the callback
        jobID - The JobID of the callbacks that should be subscribed to.
        callbackFunc - The function to invoke with the callback.
        Returns:
        An Closeable. Disposing of the return value will unsubscribe the callbackFunc .
      • subscribe

        public <TCallback extends ICallbackMsg> java.io.Closeable subscribe​(java.lang.Class<? extends TCallback> callbackType,
                                                                            Consumer<TCallback> callbackFunc)
        REgisters the provided Consumer to receive callbacks of type CallbackManager
        Type Parameters:
        TCallback - The type of callback to subscribe to.
        Parameters:
        callbackType - type of the callback
        callbackFunc - The function to invoke with the callback.
        Returns:
        An Closeable. Disposing of the return value will unsubscribe the callbackFunc .
      • register

        public void register​(in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackBase callback)
        Specified by:
        register in interface ICallbackMgrInternals
      • unregister

        public void unregister​(in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackBase callback)
        Specified by:
        unregister in interface ICallbackMgrInternals