Class CMClient

  • Direct Known Subclasses:
    SteamClient

    public abstract class CMClient
    extends java.lang.Object
    This base client handles the underlying connection to a CM server. This class should not be use directly, but through the SteamClient class.
    • 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 a ConnectedCallback. If the server that SteamKit attempts to connect to is down, a DisconnectedCallback will 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 a ConnectedCallback. If the server that SteamKit attempts to connect to is down, a DisconnectedCallback will 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 - The ServerRecord of 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)
      • 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 NetHookNetworkListener class.
      • setDebugNetworkListener

        public void setDebugNetworkListener​(IDebugNetworkListener debugNetworkListener)
        Sets the network listening interface. Use this for debugging only. For your convenience, you can use NetHookNetworkListener class.
        Parameters:
        debugNetworkListener - the listener
      • isExpectDisconnection

        public boolean isExpectDisconnection()
      • setExpectDisconnection

        public void setExpectDisconnection​(boolean expectDisconnection)