To receive callbacks from the client when there is an incoming message you have to register callback consumers with a CallbackManager object. The following code registers callbacks for connection and disconnection events.
CallbackManagermanager = newCallbackManager(steamClient);
manager.subscribe(ConnectedCallback.class, this::onConnected);
manager.subscribe(DisconnectedCallback.class, this::onDisconnected);
...
privatevoidonConnected(LoggedOnCallbackcallback) {
// handle connected event here, e.g. log in
}
privatevoidonDisconnected(DisconnectedCallbackcallback) {
// handle disconnected event here, e.g. reconnect
}
To actually start receiving the callbacks you need to call one of the run methods. Normally you would do this in a separate thread in a loop.
while (isRunning) {
manager.runWaitCallbacks(1000L);
}
Logging
By default log messages created by JavaSteam are not redirected anywhere. You can use the DefaultLogListener which simply prints log messages to the standard output. Alternatively, you can implement the LogListener interface if you want to handle the log messages yourself.