de.knup.jedi.jayshare
Class Connection

java.lang.Object
  |
  +--de.knup.jedi.jayshare.Connection

public class Connection
extends java.lang.Object

Handles a connection to a conference room

Version:
1.0 $Revision: 1.26 $
Author:
B. Pietsch

Field Summary
protected  CommunicationThread comm
          Provides background communication intelligence.
protected  JID confJID
          JID of the conference.
protected  ConnectionBean connBean
          JabberBeans connection bean to control connection to the server.
protected  FileshareListener listener
          FileshareListener listens to incoming packets and extracts usable input.
protected  Status status
          Reference to the Status instance.
 
Constructor Summary
Connection(Status status)
          Create a connection instance.
 
Method Summary
 void addConnectionListener(ConnectionListener listener)
          Add a ConnectionListener (e.g.
 void addPacketListener(PacketListener listener)
          Add another PacketListener (e.g.
 void broadcastListModification(MDate date)
          Broadcasts a list modification to the whole conference.
 void broadcastMessage(FileshareComponentBuilder builder)
          Sends a jayShare packet.
 void connect()
          Connect to the server and log in.
 void disconnect()
          Hum, we have to leave now.
 FileshareComponentBuilder makeCapability(java.util.Vector versions, java.lang.String langs, java.util.Vector xtags)
          Create a CapabilityBuilder to send a packet.
 FileshareComponentBuilder makeListModification(MDate date)
          Create a ListModificationBuilder to send a packet.
 FileshareComponentBuilder makeListReply(FileList myList)
          Create a ListreplyBuilder to send a packet.
 FileshareComponentBuilder makeListRequest()
          Create a ListRequestBuilder to send a packet.
 FileshareComponentBuilder makeServiceReply(java.lang.String proto, java.lang.String host, int port)
          Create a ServiceReplyBuilder to send a packet.
 FileshareComponentBuilder makeServiceRequest()
          Create a ServiceRequestBuilder to send a packet.
 void sendMessage(JID toAddress, FileshareComponentBuilder builder)
          Sends a jayShare packet.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

status

protected Status status
Reference to the Status instance.

connBean

protected ConnectionBean connBean
JabberBeans connection bean to control connection to the server.

listener

protected FileshareListener listener
FileshareListener listens to incoming packets and extracts usable input.

comm

protected CommunicationThread comm
Provides background communication intelligence. It automatically answers to fileshare requests, sends list modification timestamps to new users and updates file lists with incoming new ones.

confJID

protected JID confJID
JID of the conference. This is something like "jayshare@conference.jabber.org".
Constructor Detail

Connection

public Connection(Status status)
Create a connection instance. This does not connect to the server. Use the connect () method.
Parameters:
user - User name
nick - Nick name
password - Jabber password
chatroom - jayShare conference room (e.g. "jayshare")
jabberServer - Jabber server to connect to (e.g. "jabber.org")
confServer - Conference server which provides the group chat (e.g. "conferene.jabber.org")
port - Jabber server port (usually 5222)
Method Detail

addPacketListener

public void addPacketListener(PacketListener listener)
Add another PacketListener (e.g. for debugging, for integration of a chat client)

addConnectionListener

public void addConnectionListener(ConnectionListener listener)
Add a ConnectionListener (e.g. for debugging)

makeListModification

public FileshareComponentBuilder makeListModification(MDate date)
Create a ListModificationBuilder to send a packet.
Parameters:
date - Time of the last change of the export list.

makeCapability

public FileshareComponentBuilder makeCapability(java.util.Vector versions,
                                                java.lang.String langs,
                                                java.util.Vector xtags)
Create a CapabilityBuilder to send a packet.
Parameters:
versions - is a Vector of Version objects that define the clients version capabilities.
langs - is a space-seperated String that defines the supported languages.
xtags - is a Vector of XTag objects that contain additional capabilities (e.g. '

makeListRequest

public FileshareComponentBuilder makeListRequest()
Create a ListRequestBuilder to send a packet.

makeListReply

public FileshareComponentBuilder makeListReply(FileList myList)
Create a ListreplyBuilder to send a packet.
Parameters:
myList - is the export list.

makeServiceRequest

public FileshareComponentBuilder makeServiceRequest()
Create a ServiceRequestBuilder to send a packet.

makeServiceReply

public FileshareComponentBuilder makeServiceReply(java.lang.String proto,
                                                  java.lang.String host,
                                                  int port)
Create a ServiceReplyBuilder to send a packet.
Parameters:
proto - defines the Service protocol (usually "http").
host - defines the DNS server name or IP address of the download server.
port - defines the download server port.

sendMessage

public void sendMessage(JID toAddress,
                        FileshareComponentBuilder builder)
Sends a jayShare packet.
Parameters:
toAddress - is the packets target (either a single user in a conference).
builder - is the packet builder (@see makeListModification (), makeCapability (), makeListRequest (), makeListReply (), makeServiceRequest (), makeServiceReply ()).

broadcastMessage

public void broadcastMessage(FileshareComponentBuilder builder)
Sends a jayShare packet.
Parameters:
builder - is the packet builder (@see makeListModification ()).

broadcastListModification

public void broadcastListModification(MDate date)
Broadcasts a list modification to the whole conference. This should be done when the export list has changed and on the entrance to the jayShare room.

disconnect

public void disconnect()
Hum, we have to leave now.

connect

public void connect()
             throws java.net.UnknownHostException,
                    java.io.IOException,
                    NoUserListException
Connect to the server and log in.
Throws:
UnknownHostException, - IOException, NoUserListException