public final class SteamClient extends CMClient
Modifier and Type | Field and Description |
---|---|
(package private) Object |
callbackLock |
(package private) Queue<CallbackMsg> |
callbackQueue |
(package private) AtomicLong |
currentJobId |
(package private) Map<Class<? extends ClientMsgHandler>,ClientMsgHandler> |
handlers |
Constructor and Description |
---|
SteamClient() |
SteamClient(ProtocolType type)
Initializes a new instance of the
SteamClient class with a specific connection type. |
Modifier and Type | Method and Description |
---|---|
void |
addHandler(ClientMsgHandler handler)
Adds a new handler to the internal list of message handlers.
|
void |
freeLastCallback()
Frees the last callback in the queue.
|
CallbackMsg |
getCallback()
Gets the next callback object in the queue.
|
CallbackMsg |
getCallback(boolean freeLast)
Gets the next callback object in the queue, and optionally frees it.
|
<T extends ClientMsgHandler> |
getHandler(Class<T> type)
Returns a registered handler.
|
JobID |
getNextJobID()
Returns the next available JobID for job based messages.
|
(package private) void |
handleEncryptResult(IPacketMsg packetMsg) |
protected void |
onClientConnected()
Called when the client is connected to Steam3 and is ready to send messages.
|
protected void |
onClientDisconnected()
Called when the client is physically disconnected from Steam3.
|
protected void |
onClientMsgReceived(IPacketMsg packetMsg)
Called when a client message is received from the network.
|
void |
postCallback(CallbackMsg msg)
Posts a callback to the queue.
|
void |
removeHandler(Class<? extends ClientMsgHandler> handler)
Removes a registered handler by name.
|
void |
removeHandler(ClientMsgHandler handler)
Removes a registered handler.
|
CallbackMsg |
waitForCallback()
Blocks the calling thread until a callback object is posted to the queue.
|
CallbackMsg |
waitForCallback(boolean freeLast)
Blocks the calling thread until a callback object is posted to the queue, and optionally frees it.
|
CallbackMsg |
waitForCallback(boolean freeLast,
long timeout)
Blocks the calling thread until a callback object is posted to the queue, and optionally frees it.
|
CallbackMsg |
waitForCallback(long timeout)
Blocks the calling thread until a callback object is posted to the queue, or null after the timeout has elapsed.
|
connect, connect, disconnect, getLocalIP, getServersOfType, send
Map<Class<? extends ClientMsgHandler>,ClientMsgHandler> handlers
AtomicLong currentJobId
Object callbackLock
Queue<CallbackMsg> callbackQueue
public SteamClient()
public SteamClient(ProtocolType type)
SteamClient
class with a specific connection type.type
- The connection type to use.public void addHandler(ClientMsgHandler handler) throws InvalidOpenTypeException
handler
- The handler to add.IllegalArgumentException
- A handler of that type is already registered.InvalidOpenTypeException
public void removeHandler(Class<? extends ClientMsgHandler> handler)
handler
- The handler name to remove.public void removeHandler(ClientMsgHandler handler)
handler
- The handler to remove.public <T extends ClientMsgHandler> T getHandler(Class<T> type)
public CallbackMsg getCallback()
public CallbackMsg getCallback(boolean freeLast)
freeLast
- if set to true this function also frees the last callback if one existed.public CallbackMsg waitForCallback()
public CallbackMsg waitForCallback(long timeout)
timeout
- The length of time to block.public CallbackMsg waitForCallback(boolean freeLast)
freeLast
- if set to true this function also frees the last callback.public CallbackMsg waitForCallback(boolean freeLast, long timeout)
freeLast
- if set to true this function also frees the last callback.timeout
- The length of time to block.public void freeLastCallback()
public void postCallback(CallbackMsg msg)
msg
- The message.public JobID getNextJobID()
protected void onClientMsgReceived(IPacketMsg packetMsg) throws IOException
onClientMsgReceived
in class CMClient
packetMsg
- The packet message.IOException
protected void onClientDisconnected()
onClientDisconnected
in class CMClient
protected void onClientConnected()
onClientConnected
in class CMClient
void handleEncryptResult(IPacketMsg packetMsg)
Copyright © 2012. All Rights Reserved.