WhiteBoard Using RMI
WSU CEG 7370 WhiteBoard Using Java RMI
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
WhiteBoard.WbServerImpl Class Reference
+ Inheritance diagram for WhiteBoard.WbServerImpl:
+ Collaboration diagram for WhiteBoard.WbServerImpl:

Public Member Functions

void addClient (WbClient wc, String brdnm) throws java.rmi.RemoteException
 
void addLine (LineCoords ln, String brdnm) throws java.rmi.RemoteException
 
void delClient (WbClient wc, String brdnm) throws java.rmi.RemoteException
 
void sendAllLines (WbClient wc, String brdnm) throws java.rmi.RemoteException
 
 WbServerImpl (String[] args) throws Exception
 

Static Public Member Functions

static void main (String args[])
 

Private Member Functions

ABoard findAboard (String brdnm)
 
void pleaseDie ()
 
void sendAllLines (WbClient wc, ABoard ab)
 

Private Attributes

String myURL
 
Vector< ABoard > vBoards
 

Detailed Description

Definition at line 22 of file WbServerImpl.java.

Constructor & Destructor Documentation

WhiteBoard.WbServerImpl.WbServerImpl ( String[]  args) throws Exception

Definition at line 29 of file WbServerImpl.java.

References WhiteBoard.WbServerImpl.myURL, and WhiteBoard.WbServerImpl.vBoards.

Referenced by WhiteBoard.WbServerImpl.main().

29  {
30  // args = [serverID, serverMcnm]
31  vBoards = new Vector <ABoard> ();
32  myURL = Invoke.makeURL('S', args[0]);
33  Naming.rebind(myURL, this); // rmi register ourselves
34  Invoke.myPrint("WbServerImpl", myURL + " started");
35  }
Vector< ABoard > vBoards

+ Here is the caller graph for this function:

Member Function Documentation

void WhiteBoard.WbServerImpl.addClient ( WbClient  wc,
String  brdnm 
) throws java.rmi.RemoteException

Implements WhiteBoard.WbServer.

Definition at line 72 of file WbServerImpl.java.

References WhiteBoard.WbServerImpl.findAboard(), and WhiteBoard.WbServerImpl.sendAllLines().

73  {
74  ABoard ab = findAboard(brdnm);
75  if (ab == null) {
76  ab = new ABoard(brdnm);
77  vBoards.addElement(ab);
78  } else {
79  sendAllLines(wc, ab); // new client on an old board
80  }
81  ab.vClients.addElement(wc);
82  }
void sendAllLines(WbClient wc, String brdnm)
ABoard findAboard(String brdnm)

+ Here is the call graph for this function:

void WhiteBoard.WbServerImpl.addLine ( LineCoords  ln,
String  brdnm 
) throws java.rmi.RemoteException

Implements WhiteBoard.WbServer.

Definition at line 98 of file WbServerImpl.java.

References WhiteBoard.WbServerImpl.findAboard().

99  {
100  ABoard ab = findAboard(brdnm);
101  if (ab == null) return;
102 
103  ab.vLines.addElement(ln);
104 
105  // Broadcast to all the clients on this board
106  for (Enumeration e = ab.vClients.elements(); e.hasMoreElements();) {
107  WbClient wc = (WbClient) e.nextElement();
108  try {wc.updateBoard(ln);}
109  catch (Exception x) {x.printStackTrace();}
110  }
111  }
ABoard findAboard(String brdnm)

+ Here is the call graph for this function:

void WhiteBoard.WbServerImpl.delClient ( WbClient  wc,
String  brdnm 
) throws java.rmi.RemoteException

Implements WhiteBoard.WbServer.

Definition at line 84 of file WbServerImpl.java.

References WhiteBoard.WbServerImpl.findAboard(), WhiteBoard.WbServerImpl.pleaseDie(), and WhiteBoard.WbServerImpl.vBoards.

85  {
86  ABoard ab = findAboard(brdnm);
87  if (ab == null) return;
88 
89  ab.vClients.removeElement(wc);
90 
91  // If this is the last client in board, delete board
92  if (ab.vClients.size() == 0) vBoards.removeElement(ab);
93 
94  // If this was the last board, terminate this server
95  if (vBoards.size() == 0) pleaseDie();
96  }
Vector< ABoard > vBoards
ABoard findAboard(String brdnm)

+ Here is the call graph for this function:

ABoard WhiteBoard.WbServerImpl.findAboard ( String  brdnm)
private

Definition at line 50 of file WbServerImpl.java.

References WhiteBoard.WbServerImpl.vBoards.

Referenced by WhiteBoard.WbServerImpl.addClient(), WhiteBoard.WbServerImpl.addLine(), WhiteBoard.WbServerImpl.delClient(), and WhiteBoard.WbServerImpl.sendAllLines().

50  {
51  for (Enumeration e = vBoards.elements(); e.hasMoreElements();) {
52  ABoard b = (ABoard) e.nextElement();
53  if (brdnm.equals(b.boardName))
54  return b;
55  }
56  return null;
57  }
Vector< ABoard > vBoards

+ Here is the caller graph for this function:

static void WhiteBoard.WbServerImpl.main ( String  args[])
static

Definition at line 113 of file WbServerImpl.java.

References WhiteBoard.WbServerImpl.WbServerImpl().

113  {
114  try { WbServerImpl wsi = new WbServerImpl(args);}
115  catch (Exception e) {e.printStackTrace();}
116  }
WbServerImpl(String[] args)

+ Here is the call graph for this function:

void WhiteBoard.WbServerImpl.pleaseDie ( )
private

Definition at line 37 of file WbServerImpl.java.

References WhiteBoard.WbServerImpl.myURL.

Referenced by WhiteBoard.WbServerImpl.delClient().

37  {
38  int delay = 5000; // in msec, delayed death
39  Timer timer = new Timer();
40  timer.schedule( new TimerTask(){
41  public void run() {
42  try {Naming.unbind(myURL);}
43  catch (Exception e) {e.printStackTrace();}
44  Invoke.myPrint("WbServerImpl", myURL + " exits");
45  System.exit(0);
46  }
47  }, delay);
48  }

+ Here is the caller graph for this function:

void WhiteBoard.WbServerImpl.sendAllLines ( WbClient  wc,
String  brdnm 
) throws java.rmi.RemoteException

Implements WhiteBoard.WbServer.

Definition at line 59 of file WbServerImpl.java.

References WhiteBoard.WbServerImpl.findAboard().

Referenced by WhiteBoard.WbServerImpl.addClient().

60  {
61  ABoard ab = findAboard(brdnm);
62  sendAllLines(wc, ab);
63  }
void sendAllLines(WbClient wc, String brdnm)
ABoard findAboard(String brdnm)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WhiteBoard.WbServerImpl.sendAllLines ( WbClient  wc,
ABoard  ab 
)
private

Definition at line 65 of file WbServerImpl.java.

65  {
66  for (Enumeration e = ab.vLines.elements(); e.hasMoreElements(); ) {
67  try {wc.updateBoard((LineCoords) e.nextElement());}
68  catch (Exception x) {x.printStackTrace();}
69  }
70  }

Member Data Documentation

String WhiteBoard.WbServerImpl.myURL
private
Vector<ABoard> WhiteBoard.WbServerImpl.vBoards
private

The documentation for this class was generated from the following file:
Copyright © 2014 www.wright.edu/~pmateti;   thanks to doxygen