Class CallbackManager
- java.lang.Object
-
- in.dragonbra.javasteam.steam.steamclient.callbackmgr.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 theSteamClientinstance that will be posting callbacks.
-
-
Constructor Summary
Constructors Constructor Description CallbackManager(SteamClient steamClient)Initializes a new instance of theCallbackManagerclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidregister(in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackBase callback)voidrunCallbacks()Runs a single queued callback.voidrunWaitAllCallbacks(int timeout)Blocks the current thread to run all queued callbacks.voidrunWaitCallbacks()Blocks the current thread to run a single queued callback.voidrunWaitCallbacks(long timeout)Blocks the current thread to run a single queued callback.<TCallback extends ICallbackMsg>
java.io.Closeablesubscribe(java.lang.Class<? extends TCallback> callbackType, JobID jobID, Consumer<TCallback> callbackFunc)REgisters the providedConsumerto receive callbacks of typeCallbackManager<TCallback extends ICallbackMsg>
java.io.Closeablesubscribe(java.lang.Class<? extends TCallback> callbackType, Consumer<TCallback> callbackFunc)REgisters the providedConsumerto receive callbacks of typeCallbackManagervoidunregister(in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackBase callback)
-
-
-
Constructor Detail
-
CallbackManager
public CallbackManager(SteamClient steamClient)
Initializes a new instance of theCallbackManagerclass.- Parameters:
steamClient- TheSteamClientinstance 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 providedConsumerto receive callbacks of typeCallbackManager- Type Parameters:
TCallback- The type of callback to subscribe to.- Parameters:
callbackType- type of the callbackjobID- TheJobIDof 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 providedConsumerto receive callbacks of typeCallbackManager- Type Parameters:
TCallback- The type of callback to subscribe to.- Parameters:
callbackType- type of the callbackcallbackFunc- 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:
registerin interfaceICallbackMgrInternals
-
unregister
public void unregister(in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackBase callback)
- Specified by:
unregisterin interfaceICallbackMgrInternals
-
-