candy.client
Class ClientApp

java.lang.Object
  |
  +--candy.client.ClientApp

public class ClientApp
extends java.lang.Object

Class containing client application to be run on each candy user's individual machine and allow user to interface with Javaspace

Author:
Jeremy Mullendore, Jason Corso

Field Summary
(package private)  CandyTableListener candyTableListener
          listener for updates to the CandyTables (meeting, transcript, file tables)
 Channel channel
          Channel upon which chat messages are received
 ChannelListener channelListener
          listener for packets and updates on this user's channel
(package private)  java.util.Hashtable chats
          A hash table containing references to this client's current chats
(package private)  CalendarTableListener cTableListener
          A listener for updates to the Calendar Table
(package private)  CandyTable fTable
          The current ExternalFileTable
(package private)  java.util.Hashtable meetings
          A vector containing references to this client's current meetings
(package private)  Member member
          Member object of this client
(package private)  java.lang.String memberID
          MemberID is the string for the MemberID of this client
(package private)  MemberTable mTable
          A Table of the current active users logged onto the system
(package private)  MemberTableListener mTableListener
          A RMI Listener which listens on the JavaSpace for updates to the active MemberTable
(package private)  CandyTable mtgTable
          The current MeetingFileTable
(package private)  CUserList theActiveMemberView
          The displayed active member list which reflect mTable
(package private)  FileView theExternalFileView
          A Reference to the ExternalFileView ...
(package private)  LoginView theLoginView
          The LoginView for logging a user in.
(package private)  MasterChatView theMasterChatView
          A reference to the MasterChatView object of this client
(package private)  MasterMeetingView theMasterMeetingView
          hook to MasterMeetingView
(package private)  net.jini.space.JavaSpace theSpace
          A Reference to the actual space (candySpace)
(package private)  MasterTranscriptView theTranscriptView
          A reference to the MasterTranscriptView
(package private)  MainWindow theWin
          A Reference to the MainWindow object (which I own)
(package private)  CandyTable transTable
          The current TranscriptTable
(package private)  java.util.Vector wboards
          A vector containing references to this client's current whiteboards
(package private)  java.util.Vector wboardviews
          this client's current whiteboard views
(package private)  WhiteboardTable wbTable
          A list of the whiteboards -- the WhiteboardMetas that are active
 
Constructor Summary
ClientApp()
          constructor for the client app who knows only the name of the JavaSpace
 
Method Summary
 void addMeeting(Meeting m)
          add a new meeting to this client's list of active meetings
 void addMeetingMember(candy.core.packet.MeetingJoinPacket mjp)
          add a Member to a Meeting which I already know something about!
 void addToChat(candy.core.packet.ChatAddPacket message)
          called upon receipt of a ChatAddPacket, adds a Member to an existing Chat that this client is involved in
 void addTranscript(Transcript t)
          add a new Transcript to this client's list of Transcripts
 void addWBMember(candy.core.packet.WBMemberJoinPacket wbmjp)
          Add a member to an active wb I know about
 void addWBPrimitive(candy.core.packet.WBPrimitivePacket wbpp)
          Add a primitive packet to one of the whiteboards I know about
 void createChannel()
          creates the Channel that will be used by this client for communication in the JavaSpace
 Chat createChat(ChatView newView, java.util.Vector members)
          creates a new Chat for this client
 void createMeeting(java.lang.String s, int t)
          Create a meeting and inject it into the space
 void distWBPrim(Whiteboard wb, candy.core.packet.WBPrimitivePacket p)
          Distribute a whiteboard primitive into the space from one of my whiteboard views
 void doFileDownload(int row, java.io.File f)
          Do a File Download of an external file from the space
 void doFileRemove(int row)
          Do a File Removal of an external file from the space
 void doWBReturnPTD(candy.core.packet.WBReturnPTD wbptd)
          Handle when a WBReturnPTD has been issued to us from the server...
 void doWhiteboardCreate(WhiteboardView wbv)
          handle when a view of mine has created a new whiteboard.
 Member findMemberByID(java.lang.String id)
          finds the Member object corresponding to a given Member name
 Channel getChannel()
           
 ExternalFile getFile(ExternalFileMeta m)
          get an ExternalFile from the JavaSpace
 CandyTable getFileTable()
          retrieves the current table of files from the JavaSpace
 MainWindow getMainWindow()
          Return the MainWindow
 CandyTable getMeetingTable()
           
 Member getMember()
           
 java.lang.String getMemberID()
           
 MemberTable getMemberTable()
          setMemberTable sets the local mTable -- called by the listener
 CandyTable getTranscriptTable()
           
 Whiteboard getWhiteboard(WhiteboardMeta wm, WhiteboardView wbv)
          given a WhiteboardMeta, "go into the space" and get the WB And also add the whiteboard to the hash of connected whiteboards
 java.util.Vector getWhiteboardList()
           
 boolean importExternalFile(java.io.File f)
          The FileView has requested that a new ExternalFile be added to the system.
 void joinMeeting(int row)
          Join a Meeting given its row in the MeetingTable
 void killMeeting(MeetingView mv)
          this User has closed a Meeting session , do it
 void killWBSession(WhiteboardView v)
          this User has closed a WB session, handle them leaving
 void listActiveMembers()
          Lists the current active members of the system
 boolean login()
          Pushed by the gui and then pulls the id and password
 boolean login(java.lang.String ID, java.lang.String password)
          logs this client in to candy system
 boolean logout()
          Logout this session fo this ClientApp
static void main(java.lang.String[] args)
          The main routine for the clientApp
 void processMeetingChatPacket(candy.core.packet.ChatMsgPacket message)
          takes a chat message and attempts to find a meeting with which this message is associated if meeting is found, it adds this packet to the meetings packet list (for transcripting)
 candyObject read(candyObject tmpl)
          reads a packet of the given template from the JavaSpace
 candyObject read(candyObject tmpl, long wait)
          read an object from the JavaSpace
 boolean readCalendarTable()
          read the CalendarTable from the JavaSpace
 boolean readExternalFileTable()
          Reads the ExternalFileTable from the JavaSpace
 candyObject readIfExists(candyObject tmpl)
          read an object from the JavaSpace that matches the provided template
if no such object is immediately found, return
 boolean readMeetingTable()
          Reads the MeetingTable from the JavaSpace
 boolean readMemberTable()
          Reads the memberTable from the JavaSpace
 boolean readTranscriptTable()
          Reads the TranscriptTable from the JavaSpace
 boolean readWhiteboardTable()
          Reads the WhiteboardTable form the JavaSpace
 void removeChat(Chat c)
          remove a Chat from this client's list of active Chats
 void removeFromChat(candy.core.packet.ChatLeavePacket clp)
          this method is called when a member sends out a chat leave message - that they are leaving an active chat that this member is involved in
 void removeMeetingMember(candy.core.packet.MeetingLeavePacket mlp)
          called upon receipt of a MeetingLeavePacket removes a Member from the user list of a meeting which I am participating in
 void removeTranscript(int row)
          remove a transcript from the space we assume good natured group where anyone can add/remove items from the space, regardless of owner
 void removeWBMember(candy.core.packet.WBMemberLeavePacket wbmlp)
          remove a member from a whiteboard that I know about
 void sendOnChannel(candy.core.packet.ChannelPacket p)
          sendOnChannel sends a Packet on a Channel to a user
 void setCalendarTable(EntryTable et)
          setCalendarTable The Calendar itself is saying that I must update the CalendarTable...
 void setExternalFileTable(CandyTable t)
          setExternalFileTable sets the local fTable -- called by the listener
 void setMeetingTable(CandyTable t)
          sets the contents of the local meeting table --listener invoked
 void setMemberTable(MemberTable t)
          setMemberTable sets the local mTable -- called by the listener
 void setTranscriptTable(CandyTable t)
          sets the contents of the local transcript table -- called by the listener
 void setWBViewWB(WhiteboardView wbv, Whiteboard wb)
          Latent hook for a chicken-egg coding issue with WB Views and WBs
 void setWhiteboardTable(WhiteboardTable wbt)
          setWhiteboardTable sets the local wbTable -- called by the listener
 void startReceiving()
          starts the receiving of channel (chat/wb) messages to this client
 net.jini.core.entry.Entry take(net.jini.core.entry.Entry tmpl)
          takes a packet of the given template from the JavaSpace
 net.jini.core.entry.Entry takeIfExists(net.jini.core.entry.Entry tmpl)
          takes a packet of the given template from the JavaSpace
 void updateCalendarTable(EntryTable et)
          The CalendarTable was updated in the space and I noticed it My listener pulled it from the space and here it is
 void updateChat(candy.core.packet.ChatMsgPacket message)
          when new message is received, this directs it to the correct Chat
 void viewTranscript(int row)
          view a transcript stored in the space
 void write(candyObject p)
          places candyObject into javaspace so as to update other users of some change
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theSpace

net.jini.space.JavaSpace theSpace
A Reference to the actual space (candySpace)

memberID

java.lang.String memberID
MemberID is the string for the MemberID of this client

member

Member member
Member object of this client

mTable

MemberTable mTable
A Table of the current active users logged onto the system

mTableListener

MemberTableListener mTableListener
A RMI Listener which listens on the JavaSpace for updates to the active MemberTable

cTableListener

CalendarTableListener cTableListener
A listener for updates to the Calendar Table

chats

java.util.Hashtable chats
A hash table containing references to this client's current chats

wboards

java.util.Vector wboards
A vector containing references to this client's current whiteboards

wboardviews

java.util.Vector wboardviews
this client's current whiteboard views

meetings

java.util.Hashtable meetings
A vector containing references to this client's current meetings

channel

public Channel channel
Channel upon which chat messages are received

channelListener

public ChannelListener channelListener
listener for packets and updates on this user's channel

theWin

MainWindow theWin
A Reference to the MainWindow object (which I own)

theMasterChatView

MasterChatView theMasterChatView
A reference to the MasterChatView object of this client

theActiveMemberView

CUserList theActiveMemberView
The displayed active member list which reflect mTable

fTable

CandyTable fTable
The current ExternalFileTable

mtgTable

CandyTable mtgTable
The current MeetingFileTable

theMasterMeetingView

MasterMeetingView theMasterMeetingView
hook to MasterMeetingView

theExternalFileView

FileView theExternalFileView
A Reference to the ExternalFileView ... hook

transTable

CandyTable transTable
The current TranscriptTable

candyTableListener

CandyTableListener candyTableListener
listener for updates to the CandyTables (meeting, transcript, file tables)

theTranscriptView

MasterTranscriptView theTranscriptView
A reference to the MasterTranscriptView

wbTable

WhiteboardTable wbTable
A list of the whiteboards -- the WhiteboardMetas that are active

theLoginView

LoginView theLoginView
The LoginView for logging a user in. It is needed so that it can be closed when the user logs in correctly
Constructor Detail

ClientApp

public ClientApp()
constructor for the client app who knows only the name of the JavaSpace
Method Detail

getFileTable

public CandyTable getFileTable()
retrieves the current table of files from the JavaSpace
Returns:
CandyTable that is the FileTable

getMeetingTable

public CandyTable getMeetingTable()
Returns:
CandyTable that is the table of current meetings

getTranscriptTable

public CandyTable getTranscriptTable()
Returns:
CandyTable that is the table of current transcripts

addMeetingMember

public void addMeetingMember(candy.core.packet.MeetingJoinPacket mjp)
add a Member to a Meeting which I already know something about!
Parameters:
mjp - MeetingJoinPacket containing the member to be added

removeMeetingMember

public void removeMeetingMember(candy.core.packet.MeetingLeavePacket mlp)
called upon receipt of a MeetingLeavePacket removes a Member from the user list of a meeting which I am participating in
Parameters:
mlp - the packet containing the Member that is leaving and what meeting he/she is leaving

addWBPrimitive

public void addWBPrimitive(candy.core.packet.WBPrimitivePacket wbpp)
Add a primitive packet to one of the whiteboards I know about
Parameters:
wbpp - the packet containing the WBPrimitive to be added

addWBMember

public void addWBMember(candy.core.packet.WBMemberJoinPacket wbmjp)
Add a member to an active wb I know about
Parameters:
wbmjp - packet containing a Whiteboard and a Member that is joining that Whiteboard

createChannel

public void createChannel()
creates the Channel that will be used by this client for communication in the JavaSpace

getWhiteboardList

public java.util.Vector getWhiteboardList()
Returns:
the vector of WhiteboardMeta's in the JavaSpace

getWhiteboard

public Whiteboard getWhiteboard(WhiteboardMeta wm,
                                WhiteboardView wbv)
given a WhiteboardMeta, "go into the space" and get the WB And also add the whiteboard to the hash of connected whiteboards
Parameters:
wm - the WhiteboardMeta to be found
wbv - WhiteboardView for the found Whiteboard
Returns:
the Whiteboard found in the JavaSpace for the given Meta

getMember

public Member getMember()
Returns:
the Member object for the user of this Client Application

getChannel

public Channel getChannel()
Returns:
this user's Channel object

distWBPrim

public void distWBPrim(Whiteboard wb,
                       candy.core.packet.WBPrimitivePacket p)
Distribute a whiteboard primitive into the space from one of my whiteboard views
Parameters:
wb - the Whiteboard on which this primitive was added
p - the WBPrimitivePacket containing the new primitive

doFileDownload

public void doFileDownload(int row,
                           java.io.File f)
Do a File Download of an external file from the space
Parameters:
row - the row in the file table that contains the ExternalFileMeta of this File
f - the File to get from the space and store locally

viewTranscript

public void viewTranscript(int row)
view a transcript stored in the space
Parameters:
row - the row in the TranscriptTable that has the desired Transcript

removeTranscript

public void removeTranscript(int row)
remove a transcript from the space we assume good natured group where anyone can add/remove items from the space, regardless of owner

removeWBMember

public void removeWBMember(candy.core.packet.WBMemberLeavePacket wbmlp)
remove a member from a whiteboard that I know about
Parameters:
wbmlp - packet containing Member to be removed

doWBReturnPTD

public void doWBReturnPTD(candy.core.packet.WBReturnPTD wbptd)
Handle when a WBReturnPTD has been issued to us from the server... -- we just logged onto a whiteboard and must be brought up to date
Parameters:
wbptd - packet containing data to bring Whiteboard up to date

getFile

public ExternalFile getFile(ExternalFileMeta m)
get an ExternalFile from the JavaSpace
Parameters:
m - the ExternalFileMeta representing the desired ExternalFile

doFileRemove

public void doFileRemove(int row)
Do a File Removal of an external file from the space
Parameters:
row - the row number in the ExternalFileTable of the file to be removed

joinMeeting

public void joinMeeting(int row)
Join a Meeting given its row in the MeetingTable
Parameters:
row - the row in the MeetingTable of the Meeting to join

killMeeting

public void killMeeting(MeetingView mv)
this User has closed a Meeting session , do it
Parameters:
mv - the MeetingView of the Meeting this user has left

killWBSession

public void killWBSession(WhiteboardView v)
this User has closed a WB session, handle them leaving
Parameters:
v - the WhiteboardView of the Whiteboard this user has left

doWhiteboardCreate

public void doWhiteboardCreate(WhiteboardView wbv)
handle when a view of mine has created a new whiteboard. Build a WBCreatePacket and put it in the space for the server to log Also adds the whiteboard to the local hashtable of whiteboards to which I am connected Also adds myself to the whiteboard member list
Parameters:
wbv - the WhiteboardView of our new Whiteboard

getMainWindow

public MainWindow getMainWindow()
Return the MainWindow
Returns:
the main GUI window

getMemberTable

public MemberTable getMemberTable()
setMemberTable sets the local mTable -- called by the listener
Returns:
the member table

importExternalFile

public boolean importExternalFile(java.io.File f)
The FileView has requested that a new ExternalFile be added to the system. Get the FileData
Parameters:
f - the file to be added to the JavaSpace
Returns:
true if file import is successful

addMeeting

public void addMeeting(Meeting m)
add a new meeting to this client's list of active meetings
Parameters:
m - the Meeting to be added

addTranscript

public void addTranscript(Transcript t)
add a new Transcript to this client's list of Transcripts
Parameters:
t - the Transcript to be added

listActiveMembers

public void listActiveMembers()
Lists the current active members of the system

createMeeting

public void createMeeting(java.lang.String s,
                          int t)
Create a meeting and inject it into the space
Parameters:
s - the name of the new Meeting
t - flag representing if this meeting is a regular Meeting or a CodeWalkthrough

createChat

public Chat createChat(ChatView newView,
                       java.util.Vector members)
creates a new Chat for this client
Parameters:
newView - the ChatView to be associated with the new Chat
members - the Members involved in this Chat
Returns:
Chat the new chat

sendOnChannel

public void sendOnChannel(candy.core.packet.ChannelPacket p)
sendOnChannel sends a Packet on a Channel to a user
Parameters:
p - the packet to be sent on the Channel

startReceiving

public void startReceiving()
starts the receiving of channel (chat/wb) messages to this client

addToChat

public void addToChat(candy.core.packet.ChatAddPacket message)
called upon receipt of a ChatAddPacket, adds a Member to an existing Chat that this client is involved in
Parameters:
message - the ChatAddPacket containing the Member to add

processMeetingChatPacket

public void processMeetingChatPacket(candy.core.packet.ChatMsgPacket message)
takes a chat message and attempts to find a meeting with which this message is associated if meeting is found, it adds this packet to the meetings packet list (for transcripting)
Parameters:
message - the chat packet

updateChat

public void updateChat(candy.core.packet.ChatMsgPacket message)
when new message is received, this directs it to the correct Chat
Parameters:
message - a newly received chat packet

removeFromChat

public void removeFromChat(candy.core.packet.ChatLeavePacket clp)
this method is called when a member sends out a chat leave message - that they are leaving an active chat that this member is involved in
Parameters:
clp - the ChatLeavePacket

removeChat

public void removeChat(Chat c)
remove a Chat from this client's list of active Chats
Parameters:
c - the Chat to be removed

login

public boolean login()
Pushed by the gui and then pulls the id and password
Returns:
true if login is successful

login

public boolean login(java.lang.String ID,
                     java.lang.String password)
logs this client in to candy system
Parameters:
ID - the String MemberID of the member
ID - the password
Returns:
true if login is successful, false otherwise

logout

public boolean logout()
Logout this session fo this ClientApp

read

public candyObject read(candyObject tmpl)
reads a packet of the given template from the JavaSpace
Parameters:
tmpl - The template packet
Returns:
the candyObject (packet) that was read

read

public candyObject read(candyObject tmpl,
                        long wait)
read an object from the JavaSpace
Parameters:
tmpl - the template to be matched when reading from the space
wait - the amount of time in milliseconds to wait for a match
Returns:
the object read from the space

readIfExists

public candyObject readIfExists(candyObject tmpl)
read an object from the JavaSpace that matches the provided template
if no such object is immediately found, return
Parameters:
tmpl - the template to be matched
Returns:
the candyObject that was read from the space

findMemberByID

public Member findMemberByID(java.lang.String id)
finds the Member object corresponding to a given Member name
Parameters:
id - the ID tag of a Member
Returns:
the Member object of the given MemberID

readMemberTable

public boolean readMemberTable()
Reads the memberTable from the JavaSpace

readCalendarTable

public boolean readCalendarTable()
read the CalendarTable from the JavaSpace

readExternalFileTable

public boolean readExternalFileTable()
Reads the ExternalFileTable from the JavaSpace

readMeetingTable

public boolean readMeetingTable()
Reads the MeetingTable from the JavaSpace

readTranscriptTable

public boolean readTranscriptTable()
Reads the TranscriptTable from the JavaSpace

readWhiteboardTable

public boolean readWhiteboardTable()
Reads the WhiteboardTable form the JavaSpace

setCalendarTable

public void setCalendarTable(EntryTable et)
setCalendarTable The Calendar itself is saying that I must update the CalendarTable... Take the EntryTable from the space, and replace it with this one

setExternalFileTable

public void setExternalFileTable(CandyTable t)
setExternalFileTable sets the local fTable -- called by the listener

setMeetingTable

public void setMeetingTable(CandyTable t)
sets the contents of the local meeting table --listener invoked

setTranscriptTable

public void setTranscriptTable(CandyTable t)
sets the contents of the local transcript table -- called by the listener

setMemberTable

public void setMemberTable(MemberTable t)
setMemberTable sets the local mTable -- called by the listener

setWBViewWB

public void setWBViewWB(WhiteboardView wbv,
                        Whiteboard wb)
Latent hook for a chicken-egg coding issue with WB Views and WBs

setWhiteboardTable

public void setWhiteboardTable(WhiteboardTable wbt)
setWhiteboardTable sets the local wbTable -- called by the listener

take

public net.jini.core.entry.Entry take(net.jini.core.entry.Entry tmpl)
takes a packet of the given template from the JavaSpace
Parameters:
tmpl - The template packet

takeIfExists

public net.jini.core.entry.Entry takeIfExists(net.jini.core.entry.Entry tmpl)
takes a packet of the given template from the JavaSpace
Parameters:
tmpl - The template packet

updateCalendarTable

public void updateCalendarTable(EntryTable et)
The CalendarTable was updated in the space and I noticed it My listener pulled it from the space and here it is

write

public void write(candyObject p)
places candyObject into javaspace so as to update other users of some change
Parameters:
p - update packet

getMemberID

public java.lang.String getMemberID()
Returns:
this user's MemberID

main

public static void main(java.lang.String[] args)
The main routine for the clientApp
Parameters:
args - Arguments from the command-line