wtanaka.praya.bnet
Class BnetClient

java.lang.Object
  |
  +--wtanaka.praya.Protocol
        |
        +--wtanaka.praya.bnet.BnetClient
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable

public class BnetClient
extends Protocol
implements java.lang.Runnable

Main battle.net client class.

Return to Sourceforge or the Praya Homepage

Version:
$Name: $ $Date: 2002/07/14 19:36:25 $
Author:
$Author: wtanaka $
See Also:
Serialized Form

Field Summary
static java.lang.String AWAY
           
private  java.net.Socket clientSocket
           
static int CONF_CHANNEL
           
static int CONF_ITEM_COUNT
           
static int CONF_PASSWD
           
static int CONF_SERVER
           
static int CONF_STATUS
           
static int CONF_USERNAME
           
static java.lang.String DEFAULT_USERNAME
           
private static int floodTimeout
           
(package private)  java.util.Vector infoLines
           
private  long lastCommandTime
           
private  boolean lastLineWasUserLine
           
private  long lastTimeSent
           
private  ConfigItem[] m_configItems
           
private  int m_port
          Port to connect to (default to 6112)
private  long millisecsPerCharacter
           
static java.lang.String OFFLINE
           
static java.lang.String ONLINE
           
static java.lang.String[] s_statusList
           
private  java.io.BufferedReader socketInput
           
private  java.io.PrintWriter socketOutput
           
private  java.util.Vector userTypeVector
           
private  java.util.Vector userVector
           
 
Fields inherited from class wtanaka.praya.Protocol
descriptionListeners, iAmGarbage, m_buddyList, m_configPanel, m_currentDescription, m_messageListeners, recipientListeners
 
Constructor Summary
BnetClient()
          Constructor to make praya happy, since Protocols are constructed with newInstance
BnetClient(java.lang.String username, java.lang.String password)
          Constructor
BnetClient(java.lang.String username, java.lang.String password, java.lang.String hostname, int port)
          Constructor
 
Method Summary
 void checkForNewMessages(boolean a)
          Checks for new messages on the protocol.
private  void collectInfoLine(java.lang.String unQuotedInfoLine)
           
 void connect()
          Connects to the network, if that makes any sense.
 CommandInterface[] consoleCommands()
          Returns a list of commands available through this console.
 void disconnect()
          Disconnects from the network, if that makes any sense.
 ConfigItem[] getConfiguration()
           
 java.lang.String getCurrentChannel()
          Returns the current channel for the user.
 Recipient getDefaultRecipient()
           
static java.awt.Image getIcon()
           
 ProtoObj getObjInstance(NormalFolder root)
          Returns the sole instance of the ProtoObj for this protocol instance, creating a new one if necessary.
 java.lang.String getPassword()
           
 int getPort()
           
static java.lang.String getProtocolDescription()
          Used to describe the class of this protocol, before any instances have been created.
 java.lang.String getServer()
           
 java.lang.String getUsername()
           
private  void initConfigItems()
           
 boolean isConnected()
          Returns if the protocol is connected right now.
 void joinChannel(java.lang.String channelName)
           
private  void parseServerLine(java.lang.String line)
           
private  void readConfigFromFile()
          Reads .praya/bnetrc
 void run()
           
private  void sendImmediate(java.lang.String command)
           
private  void sendInfoLine()
           
 void sendToChannel(java.lang.String textToSend)
           
 void sendToUser(java.lang.String username, java.lang.String textToSend)
           
private  void sendWaitingMesasges()
           
private  void sendWithNoFlood(java.lang.String command)
           
 void setAwayMessage(java.lang.String awayMsg)
           
 void setCurrentChannel(java.lang.String channel)
          Sets the current channel
 void setMillisecondsPerCharacter(long milsPerChar)
          Sets typing speed in milliseconds per character
 void setPassword(java.lang.String pass)
           
 void setPort(int port)
           
 void setServer(java.lang.String server)
           
 void setStatus(Status status)
          Sets the currently connected user's status to the given status.
 void setUnAway()
           
 void setUsername(java.lang.String s)
           
private  java.lang.String unQuote(java.lang.String line)
           
private  void updateCurrentDescription()
           
 
Methods inherited from class wtanaka.praya.Protocol
addDescriptionListener, addListener, addRecipient, addRecipientListener, changeRecipientStatus, clearBuddyList, console, fireDescriptionChanged, fireRecipientAppeared, fireRecipientChanged, fireRecipientDisappeared, getBuddies, getConfigPanelInstance, getCurrentDescription, getStatusForBuddy, initialize, isGarbage, markAsGarbage, pushMessage, readObject, removeDescriptionListener, removeListener, removeRecipient, removeRecipientListener, setCurrentDescription, writeObject
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CONF_USERNAME

public static final int CONF_USERNAME

CONF_PASSWD

public static final int CONF_PASSWD

CONF_SERVER

public static final int CONF_SERVER

CONF_STATUS

public static final int CONF_STATUS

CONF_CHANNEL

public static final int CONF_CHANNEL

CONF_ITEM_COUNT

public static final int CONF_ITEM_COUNT

ONLINE

public static final java.lang.String ONLINE

OFFLINE

public static final java.lang.String OFFLINE

AWAY

public static final java.lang.String AWAY

s_statusList

public static final java.lang.String[] s_statusList

DEFAULT_USERNAME

public static final java.lang.String DEFAULT_USERNAME

m_configItems

private ConfigItem[] m_configItems

clientSocket

private java.net.Socket clientSocket

socketOutput

private java.io.PrintWriter socketOutput

socketInput

private java.io.BufferedReader socketInput

m_port

private int m_port
Port to connect to (default to 6112)

floodTimeout

private static final int floodTimeout

millisecsPerCharacter

private long millisecsPerCharacter

lastTimeSent

private long lastTimeSent

lastCommandTime

private long lastCommandTime

lastLineWasUserLine

private boolean lastLineWasUserLine

userVector

private java.util.Vector userVector

userTypeVector

private java.util.Vector userTypeVector

infoLines

java.util.Vector infoLines
Constructor Detail

BnetClient

public BnetClient()
Constructor to make praya happy, since Protocols are constructed with newInstance

BnetClient

public BnetClient(java.lang.String username,
                  java.lang.String password)
Constructor

BnetClient

public BnetClient(java.lang.String username,
                  java.lang.String password,
                  java.lang.String hostname,
                  int port)
Constructor
Method Detail

initConfigItems

private final void initConfigItems()

readConfigFromFile

private void readConfigFromFile()
Reads .praya/bnetrc

connect

public void connect()
             throws java.io.IOException
Description copied from class: Protocol
Connects to the network, if that makes any sense. skip if it does not.
Overrides:
connect in class Protocol
Throws:
java.io.IOException - if the socket cannot be created.

disconnect

public void disconnect()
Description copied from class: Protocol
Disconnects from the network, if that makes any sense. skip if it does not.
Overrides:
disconnect in class Protocol

isConnected

public boolean isConnected()
Description copied from class: Protocol
Returns if the protocol is connected right now. Good for telling if you need to call connect() again after the connection dies.
Overrides:
isConnected in class Protocol

getConfiguration

public ConfigItem[] getConfiguration()
Overrides:
getConfiguration in class Protocol
Following copied from class: wtanaka.praya.Protocol
Returns:
(self != null) list of configuration items for this protocol.

updateCurrentDescription

private void updateCurrentDescription()

setServer

public void setServer(java.lang.String server)

getServer

public java.lang.String getServer()

setPort

public void setPort(int port)

getPort

public int getPort()

setUsername

public void setUsername(java.lang.String s)

getUsername

public java.lang.String getUsername()

setPassword

public void setPassword(java.lang.String pass)

getPassword

public java.lang.String getPassword()

getCurrentChannel

public java.lang.String getCurrentChannel()
Returns the current channel for the user.

setCurrentChannel

public void setCurrentChannel(java.lang.String channel)
Sets the current channel

setMillisecondsPerCharacter

public void setMillisecondsPerCharacter(long milsPerChar)
Sets typing speed in milliseconds per character

sendImmediate

private void sendImmediate(java.lang.String command)
                    throws java.io.IOException

sendWithNoFlood

private void sendWithNoFlood(java.lang.String command)

joinChannel

public void joinChannel(java.lang.String channelName)
                 throws java.io.IOException

setUnAway

public void setUnAway()
               throws java.io.IOException

setAwayMessage

public void setAwayMessage(java.lang.String awayMsg)
                    throws java.io.IOException

sendToChannel

public void sendToChannel(java.lang.String textToSend)
                   throws java.io.IOException

sendToUser

public void sendToUser(java.lang.String username,
                       java.lang.String textToSend)
                throws java.io.IOException

setStatus

public void setStatus(Status status)
               throws java.io.IOException
Description copied from class: Protocol
Sets the currently connected user's status to the given status.
Overrides:
setStatus in class Protocol

unQuote

private java.lang.String unQuote(java.lang.String line)

sendWaitingMesasges

private void sendWaitingMesasges()

collectInfoLine

private void collectInfoLine(java.lang.String unQuotedInfoLine)

sendInfoLine

private void sendInfoLine()

parseServerLine

private void parseServerLine(java.lang.String line)

consoleCommands

public CommandInterface[] consoleCommands()
Description copied from class: Protocol
Returns a list of commands available through this console.
Overrides:
consoleCommands in class Protocol

run

public void run()
Specified by:
run in interface java.lang.Runnable

getObjInstance

public ProtoObj getObjInstance(NormalFolder root)
Description copied from class: Protocol
Returns the sole instance of the ProtoObj for this protocol instance, creating a new one if necessary. This should replace getConfigPanelInstance later.
Overrides:
getObjInstance in class Protocol

checkForNewMessages

public void checkForNewMessages(boolean a)
Description copied from class: Protocol
Checks for new messages on the protocol. This might make sense for nntp/usenet, email, etc. but not for irc, gale, zephyr, icq. If any new messages are found, push them.
Overrides:
checkForNewMessages in class Protocol
Following copied from class: wtanaka.praya.Protocol
Parameters:
isAutomatic - true if the check is generated automatically with a timer. false if the check is generated manually by the user.

getDefaultRecipient

public Recipient getDefaultRecipient()
Overrides:
getDefaultRecipient in class Protocol

getProtocolDescription

public static java.lang.String getProtocolDescription()
Description copied from class: Protocol
Used to describe the class of this protocol, before any instances have been created.

getIcon

public static java.awt.Image getIcon()