Android Open Source - steamchat Steam Client






From Project

Back to project page steamchat.

License

The source code is released under:

Apache License

If you think the Android project steamchat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kevelbreh.steamchat.steam;
/*w ww .j  a va 2  s .  c om*/
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;

import com.kevelbreh.steamchat.SteamChat;
import com.kevelbreh.steamchat.account.SteamAccount;
import com.kevelbreh.steamchat.steam.handler.AuthenticationHandler;
import com.kevelbreh.steamchat.steam.handler.IEventHandler;
import com.kevelbreh.steamchat.steam.handler.IHandler;
import com.kevelbreh.steamchat.steam.handler.FriendsHandler;
import com.kevelbreh.steamchat.steam.handler.MessageDebugHandler;
import com.kevelbreh.steamchat.steam.network.TCPConnection;
import com.kevelbreh.steamchat.steam.network.packet.Packet;

import java.util.ArrayList;
import java.util.List;

/**
 * Steam client class to provide interaction with the steam protocol.  Interfacing directly with
 * the connection is scary so this class has been created.
 *
 * Authenticate in this class.
 */
public class SteamClient implements IHandler {

    /**
     * Android context.
     */
    private Context mContext;

    /**
     * The users steam account on the android device.
     */
    private SteamAccount mAccount;

    /**
     * Android service controlling running the client.
     */
    private SteamService mSteamService;

    /**
     * Connection to the Steam network.  This runs on it's own thread.
     */
    private TCPConnection connection;

    /**
     * A list of handlers for the Steam client.
     */
    private List<IEventHandler> handlers;

    private String source;
    private int port;

    /**
     *
     * @param source ip of the server address.
     * @param port of the server address.
     */
    public SteamClient(final SteamService service, final String source, final int port) {
        this.source = source;
        this.port = port;

        mContext = service.getApplicationContext();
        mSteamService = service;

        handlers = new ArrayList<IEventHandler>();
        handlers.add(new MessageDebugHandler(this));
        handlers.add(new FriendsHandler(this));
        handlers.add(new AuthenticationHandler(this));
    }

    /**
     * Set the account of the SteamClient.
     * @param account the account.
     */
    public void setAccount(SteamAccount account) {
        mAccount = account;
    }

    /**
     * @return the steam account of the user.
     */
    public SteamAccount getAccount() {
        return mAccount;
    }

    /**
     * Reconnect to the steam network.
     */
    public void connect() {
        connection = new TCPConnection(this.source, this.port, this);
        connection.setDaemon(true);
        connection.start();
    }

    /**
     * Disconnect from the steam network.
     */
    public void reconnect() {
        if (connection != null) {
            connection.disconnect();
        }

        connect();
    }

    /**
     * @param packet to be added to the queue.
     */
    public void send(Packet packet) {
        connection.addPacketQueue(packet);
    }

    /**
     * @return the Steam connection.
     */
    public TCPConnection getConnection() {
        return connection;
    }

    /**
     * @return the android application context.
     */
    public Context getContext() {
        return mContext;
    }

    /**
     * @return the android service running the steam client.
     */
    public SteamService getService() {
        return mSteamService;
    }

    /**
     * Tell all the listeners that we have authenticated.
     */
    public void authenticated() {
        SteamChat.debug(this, "Authenticated to Steam network");

        for (IEventHandler handler : this.handlers) {
            handler.onAuthenticated(this);
        }
    }

    @Override
    public void onEventReceived(TCPConnection connection, int type, Packet packet) {
        //SteamChat.debug(this, "New event received: " + type);

        for (IEventHandler handler : this.handlers) {
            handler.onEventReceived(this, type, packet);
        }
    }

    @Override
    public void onConnected(TCPConnection connection) {
        SteamChat.debug(this, "Connected to Steam network");

        for (IEventHandler handler : this.handlers) {
            handler.onConnected(this);
        }
    }

    @Override
    public void onDisconnected(TCPConnection connection) {
        SteamChat.debug(this, "Disconnected from Steam network");

        for (IEventHandler handler : this.handlers) {
            handler.onDisconnected(this);
        }

        //reconnect();
    }
}




Java Source Code List

com.kevelbreh.steamchat.SteamChat.java
com.kevelbreh.steamchat.account.AuthenticatorService.java
com.kevelbreh.steamchat.account.Authenticator.java
com.kevelbreh.steamchat.account.SteamAccount.java
com.kevelbreh.steamchat.activity.AuthenticationActivity.java
com.kevelbreh.steamchat.activity.ConversationActivity.java
com.kevelbreh.steamchat.activity.FriendsActivity.java
com.kevelbreh.steamchat.activity.InteractionsActivity.java
com.kevelbreh.steamchat.activity.LauncherActivity.java
com.kevelbreh.steamchat.activity.SettingsActivity.java
com.kevelbreh.steamchat.fragment.ConversationFragment.java
com.kevelbreh.steamchat.fragment.FriendsFragment.java
com.kevelbreh.steamchat.fragment.InteractionsFragment.java
com.kevelbreh.steamchat.fragment.SettingsFragment.java
com.kevelbreh.steamchat.provider.SteamProviderUtils.java
com.kevelbreh.steamchat.provider.SteamProvider.java
com.kevelbreh.steamchat.provider.content.InteractionContentItem.java
com.kevelbreh.steamchat.provider.content.PersonaContentItem.java
com.kevelbreh.steamchat.provider.content.UserContentItem.java
com.kevelbreh.steamchat.steam2.SteamConnection.java
com.kevelbreh.steamchat.steam2.SteamEventBus.java
com.kevelbreh.steamchat.steam2.SteamService.java
com.kevelbreh.steamchat.steam2.handler.ConnectionHandler.java
com.kevelbreh.steamchat.steam2.handler.FriendHandler.java
com.kevelbreh.steamchat.steam2.handler.MessageHandler.java
com.kevelbreh.steamchat.steam2.handler.UserHandler.java
com.kevelbreh.steamchat.steam2.packet.Packet.java
com.kevelbreh.steamchat.steam2.packet.ProtoPacket.java
com.kevelbreh.steamchat.steam.SteamClient.java
com.kevelbreh.steamchat.steam.SteamID.java
com.kevelbreh.steamchat.steam.SteamServiceHandler.java
com.kevelbreh.steamchat.steam.SteamService.java
com.kevelbreh.steamchat.steam.handler2.ConnectionHandler.java
com.kevelbreh.steamchat.steam.handler2.FriendHandler.java
com.kevelbreh.steamchat.steam.handler2.Handler.java
com.kevelbreh.steamchat.steam.handler2.UserHandler.java
com.kevelbreh.steamchat.steam.handler.AEventHandler.java
com.kevelbreh.steamchat.steam.handler.AuthenticationHandler.java
com.kevelbreh.steamchat.steam.handler.FriendsHandler.java
com.kevelbreh.steamchat.steam.handler.IEventHandler.java
com.kevelbreh.steamchat.steam.handler.IHandler.java
com.kevelbreh.steamchat.steam.handler.MessageDebugHandler.java
com.kevelbreh.steamchat.steam.language.Language.java
com.kevelbreh.steamchat.steam.language.Message.java
com.kevelbreh.steamchat.steam.network.TCPConnection.java
com.kevelbreh.steamchat.steam.network.packet.ChannelEncryptRequest.java
com.kevelbreh.steamchat.steam.network.packet.ChannelEncryptResponse.java
com.kevelbreh.steamchat.steam.network.packet.ChannelEncryptResult.java
com.kevelbreh.steamchat.steam.network.packet.ClientLogOnResponse.java
com.kevelbreh.steamchat.steam.network.packet.ClientLogOn.java
com.kevelbreh.steamchat.steam.network.packet.HeartBeat.java
com.kevelbreh.steamchat.steam.network.packet.MultiPacket.java
com.kevelbreh.steamchat.steam.network.packet.Packet.java
com.kevelbreh.steamchat.steam.network.packet.ProtoPacket.java
com.kevelbreh.steamchat.steam.proto.DescriptorsProto.java
com.kevelbreh.steamchat.steam.proto.EncryptedAppTicketProto.java
com.kevelbreh.steamchat.steam.proto.SteamMessagesBaseProto.java
com.kevelbreh.steamchat.steam.proto.SteamMessagesClientServerProto.java
com.kevelbreh.steamchat.steam.security.AsnKeyParser.java
com.kevelbreh.steamchat.steam.security.AsnParser.java
com.kevelbreh.steamchat.steam.security.BerDecodeException.java
com.kevelbreh.steamchat.steam.security.Cryptography.java
com.kevelbreh.steamchat.steam.security.NetEncryption.java
com.kevelbreh.steamchat.steam.security.PublicKey.java
com.kevelbreh.steamchat.steam.security.RSA.java
com.kevelbreh.steamchat.steam.util.BinaryReader.java
com.kevelbreh.steamchat.steam.util.BinaryWriter.java
com.kevelbreh.steamchat.steam.util.BitVector64.java
com.kevelbreh.steamchat.steam.util.JenkinsHash.java
com.kevelbreh.steamchat.util.AServiceActivity.java
com.kevelbreh.steamchat.util.Dump.java
com.kevelbreh.steamchat.util.MiscUtils.java
com.kevelbreh.steamchat.widget.adapter.ChatAdapter.java
com.kevelbreh.steamchat.widget.adapter.ConversationAdapter.java
com.kevelbreh.steamchat.widget.adapter.FriendAdapter.java
com.kevelbreh.steamchat.widget.view.AvatarView.java
com.kevelbreh.steamchat.widget.view.FriendInteractionsView.java