de.knup.jedi.jayshare
Class CommunicationThread

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

public class CommunicationThread
extends java.lang.Object
implements JayPacketListener

CommunicationThread handles all the background communication of the client. It implements recommended behavoir of a jayShare client:

Version:
0.2 $Revision: 1.21 $
Author:
B. Pietsch

Field Summary
private  Connection conn
          Reference to the connection instance
private  MDate modDate
          Modification date of the export list
private  Status status
          Reference to the status instance
 
Constructor Summary
CommunicationThread(Connection connection, Status status)
          Create a CommunicationThread instance.
 
Method Summary
private  boolean addUser(java.lang.String hashedID, java.lang.String nick)
          Add a user to the lookup list.
 void getAvailable(JID from)
          A new user is available.
 void getCapability(JID from, Capability packet)
          A client sent its capabilities.
 void getListModification(JID from, ListModification packet)
          A user sent a list modification.
 void getListReply(JID from, ListReply packet)
          A user sent its export list.
 void getListRequest(JID from, ListRequest packet)
          A user wants our export list.
 void getServiceReply(JID from, ServiceReply packet)
          A user sent its service information.
 void getServiceRequest(JID from, ServiceRequest packet)
          A user wants to know our download server information.
 void getUnavailable(JID from)
          A user leaves the conference.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

modDate

private MDate modDate
Modification date of the export list

conn

private Connection conn
Reference to the connection instance

status

private Status status
Reference to the status instance
Constructor Detail

CommunicationThread

public CommunicationThread(Connection connection,
                           Status status)
Create a CommunicationThread instance.
Parameters:
connection - is the Connection instance.
status - is the Status instance.
Method Detail

addUser

private boolean addUser(java.lang.String hashedID,
                        java.lang.String nick)
Add a user to the lookup list. The lookup list contains all currently active users. If a new user is present, his/her hash and nick are insert into the lookup list.
Parameters:
hashedID - is the hashed Jabber ID.
nick - is the nickname the user currently uses.
Returns:
if the combination of hashedID and nick is valid. If the hash is already assigned to a nickname, it returns false.

getAvailable

public void getAvailable(JID from)
A new user is available.
Specified by:
getAvailable in interface JayPacketListener
Parameters:
from - is the Jabber ID of the user in the conference room (e.g. "jayshare@jabber.org/nick"). Send her/him the list modification time of the export list.

getUnavailable

public void getUnavailable(JID from)
A user leaves the conference.
Specified by:
getUnavailable in interface JayPacketListener
Parameters:
from - is the Jabber ID of the user in the conference room (e.g. "jayshare@jabber.org/nick").

getListModification

public void getListModification(JID from,
                                ListModification packet)
A user sent a list modification.
Specified by:
getListModification in interface JayPacketListener
Parameters:
from - is the Jabber ID.
packet - is the ListModification information. If the timestamp is newer than the one in our own list, then we will request the list.

getCapability

public void getCapability(JID from,
                          Capability packet)
A client sent its capabilities.
Specified by:
getCapability in interface JayPacketListener
Parameters:
from - is the Jabber ID.
packet - is the Capability information. This is right now ignored.

getListRequest

public void getListRequest(JID from,
                           ListRequest packet)
A user wants our export list.
Specified by:
getListRequest in interface JayPacketListener
Parameters:
from - is the Jabber ID.
packet - is the ListRequest information (empty). We will send our export list to her/him.

getListReply

public void getListReply(JID from,
                         ListReply packet)
A user sent its export list.
Specified by:
getListReply in interface JayPacketListener
Parameters:
from - is the Jabber ID.
packet - is the export list. Update/Insert the list into the

getServiceRequest

public void getServiceRequest(JID from,
                              ServiceRequest packet)
A user wants to know our download server information.
Specified by:
getServiceRequest in interface JayPacketListener
Parameters:
from - is the Jabber ID.
packet - is the ServiceRequest information (empty). Send protocol, host and port of our download server, if we have one.

getServiceReply

public void getServiceReply(JID from,
                            ServiceReply packet)
A user sent its service information.
Specified by:
getServiceReply in interface JayPacketListener
Parameters:
from - is the Jabber ID.
packet - is the ServiceReply information. Insert the download server information into the ServiceLookupList.