Class COM.roguewave.jchat.Connection
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.roguewave.jchat.Connection

java.lang.Object
   |
   +----COM.roguewave.jchat.Connection

public class Connection
extends Object
The Connection class.

The Connection class adds a layer of abstraction to a socket-pair relationship. There must be two instances of a Connection, one on the server and one on the client. The setClient() and setServer() methods are provided to specify whether a particular instance of a Connection is a client or a server.

A Connection instantiates a Reader that will notify a Dispatcher implementation when a complete command is received.

See Also:
Dispatcher, Reader

Constructor Index

 o Connection(Socket, Dispatcher)
Creates a Connection on the specified socket.

Method Index

 o close()
Safely close the Connection.
 o getUser()
Return the user of this connection.
 o send(String[])
Send an array of strings across the socket.
 o send(String)
Send a String across the socket.
 o setClient(String)
Specify that this instance of the Connection is for the client.
 o setServer()
Specify that this instance of the Connection is for the server.

Constructors

 o Connection
  public Connection(Socket aSocket,
                    Dispatcher aDispatcher)
Creates a Connection on the specified socket. The specified Dispatcher is notified when a complete command is read from the socket.

Methods

 o setClient
  public void setClient(String aUser)
Specify that this instance of the Connection is for the client. A name representing a user is a required parameter.
 o setServer
  public void setServer()
Specify that this instance of the Connection is for the server.
 o getUser
  public String getUser()
Return the user of this connection.
Returns:
Returns a String representing the user of this connection.
 o send
  public synchronized void send(String data[])
Send an array of strings across the socket.
 o send
  public synchronized void send(String data)
Send a String across the socket.
 o close
  public synchronized void close()
Safely close the Connection.

All Packages  Class Hierarchy  This Package  Previous  Next  Index