Package in.dragonbra.javasteam.steam
Class CMClient
- java.lang.Object
-
- in.dragonbra.javasteam.steam.CMClient
-
- Direct Known Subclasses:
SteamClient
public abstract class CMClient extends java.lang.ObjectThis base client handles the underlying connection to a CM server. This class should not be use directly, but through theSteamClientclass.
-
-
Constructor Summary
Constructors Constructor Description CMClient(SteamConfiguration configuration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()Connects this client to a Steam3 server.voidconnect(ServerRecord cmServer)Connects this client to a Steam3 server.voiddisconnect()Disconnects this client.java.lang.IntegergetCellID()SteamConfigurationgetConfiguration()longgetConnectionTimeout()Gets or sets the connection timeout used when connecting to the Steam server.java.net.InetSocketAddressgetCurrentEndpoint()Returns the current endpoint this client is connected to.IDebugNetworkListenergetDebugNetworkListener()java.net.InetAddressgetLocalIP()Returns the local IP of this client.static IPacketMsggetPacketMsg(byte[] data)SmartCMServerListgetServers()java.util.List<java.net.InetSocketAddress>getServers(EServerType type)Returns the list of servers matching the given typejava.lang.IntegergetSessionID()Gets the session ID of this client.longgetSessionToken()SteamIDgetSteamID()Gets the SteamID of this client.EUniversegetUniverse()Gets the universe of this client.booleanisConnected()Gets a value indicating whether this instance is isConnected to the remote CM server.booleanisExpectDisconnection()protected voidonClientConnected()Called when the client is securely isConnected to Steam3.protected voidonClientDisconnected(boolean userInitiated)Called when the client is physically disconnected from Steam3.protected booleanonClientMsgReceived(IPacketMsg packetMsg)voidsend(IClientMsg msg)Sends the specified client message to the server.voidsetDebugNetworkListener(IDebugNetworkListener debugNetworkListener)Sets the network listening interface.voidsetExpectDisconnection(boolean expectDisconnection)
-
-
-
Constructor Detail
-
CMClient
public CMClient(SteamConfiguration configuration)
-
-
Method Detail
-
connect
public void connect()
Connects this client to a Steam3 server. This begins the process of connecting and encrypting the data channel between the client and the server. Results are returned asynchronously in aConnectedCallback. If the server that SteamKit attempts to connect to is down, aDisconnectedCallbackwill be posted instead. SteamKit will not attempt to reconnect to Steam, you must handle this callback and call Connect again preferably after a short delay. SteamKit will randomly select a CM server from its internal list.
-
connect
public void connect(ServerRecord cmServer)
Connects this client to a Steam3 server. This begins the process of connecting and encrypting the data channel between the client and the server. Results are returned asynchronously in aConnectedCallback. If the server that SteamKit attempts to connect to is down, aDisconnectedCallbackwill be posted instead. SteamKit will not attempt to reconnect to Steam, you must handle this callback and call Connect again preferably after a short delay.- Parameters:
cmServer- TheServerRecordof the CM server to connect to.
-
disconnect
public void disconnect()
Disconnects this client.
-
send
public void send(IClientMsg msg)
Sends the specified client message to the server. This method automatically assigns the correct SessionID and SteamID of the message.- Parameters:
msg- The client message to send.
-
getServers
public java.util.List<java.net.InetSocketAddress> getServers(EServerType type)
Returns the list of servers matching the given type- Parameters:
type- Server type requested- Returns:
- List of server endpoints
-
onClientMsgReceived
protected boolean onClientMsgReceived(IPacketMsg packetMsg)
-
onClientConnected
protected void onClientConnected()
Called when the client is securely isConnected to Steam3.
-
onClientDisconnected
protected void onClientDisconnected(boolean userInitiated)
Called when the client is physically disconnected from Steam3.- Parameters:
userInitiated- whether the disconnect was initialized by the client
-
getPacketMsg
public static IPacketMsg getPacketMsg(byte[] data)
-
getConfiguration
public SteamConfiguration getConfiguration()
-
getServers
public SmartCMServerList getServers()
- Returns:
- Bootstrap list of CM servers.
-
getLocalIP
public java.net.InetAddress getLocalIP()
Returns the local IP of this client.- Returns:
- The local IP.
-
getCurrentEndpoint
public java.net.InetSocketAddress getCurrentEndpoint()
Returns the current endpoint this client is connected to.- Returns:
- The current endpoint.
-
getUniverse
public EUniverse getUniverse()
Gets the universe of this client.- Returns:
- The universe.
-
isConnected
public boolean isConnected()
Gets a value indicating whether this instance is isConnected to the remote CM server.- Returns:
- true if this instance is isConnected; otherwise, false.
-
getSessionToken
public long getSessionToken()
- Returns:
- the session token assigned to this client from the AM.
-
getCellID
public java.lang.Integer getCellID()
- Returns:
- the Steam recommended Cell ID of this client. This value is assigned after a logon attempt has succeeded. This value will be null if the client is logged off of Steam.
-
getSessionID
public java.lang.Integer getSessionID()
Gets the session ID of this client. This value is assigned after a logon attempt has succeeded. This value will be null if the client is logged off of Steam.- Returns:
- The session ID.
-
getSteamID
public SteamID getSteamID()
Gets the SteamID of this client. This value is assigned after a logon attempt has succeeded. This value will be null if the client is logged off of Steam.- Returns:
- The SteamID.
-
getConnectionTimeout
public long getConnectionTimeout()
Gets or sets the connection timeout used when connecting to the Steam server.- Returns:
- The connection timeout.
-
getDebugNetworkListener
public IDebugNetworkListener getDebugNetworkListener()
- Returns:
- the network listening interface. Use this for debugging only.
For your convenience, you can use
NetHookNetworkListenerclass.
-
setDebugNetworkListener
public void setDebugNetworkListener(IDebugNetworkListener debugNetworkListener)
Sets the network listening interface. Use this for debugging only. For your convenience, you can useNetHookNetworkListenerclass.- Parameters:
debugNetworkListener- the listener
-
isExpectDisconnection
public boolean isExpectDisconnection()
-
setExpectDisconnection
public void setExpectDisconnection(boolean expectDisconnection)
-
-