diff options
Diffstat (limited to 'java/apps/NexusII')
59 files changed, 0 insertions, 5025 deletions
diff --git a/java/apps/NexusII/README b/java/apps/NexusII/README deleted file mode 100644 index 60a630cef5a..00000000000 --- a/java/apps/NexusII/README +++ /dev/null @@ -1,58 +0,0 @@ -Nexus II - A chat application in Java with image support --------------------------------------------------------- - - Rajeev Bector (rajeev@cs.wustl.edu) - Aravind Gopalan (aravind@cs.wustl.edu) - Sumedh Mungee (sumedh@cs.wustl.edu) - -This is the README file. This distribution contains the NexusII -server, which is a java application that can be started by a command -similar to the one contained in the sample "start" shell-script. - -It also contains a "start.html" file, which serves as an example on how -a client applet can be included within a .html file. - -A sample use of this, alongwith a simple users manual, can be found at -http://cumbia.cs.wustl.edu/NexusII/ - -Compiling (optional, all the class files are already present) -------------------------------------------------------------- - -All the source .java files, alongwith the makefile should be placed in -the same directory, and can then be compiled using make. - -The client/server use the following packages: - - awtCommand: This package provides a GUI toolkit for the applet - ACE: This is used both by the client/server for - networking. ACE documentation can be found at: - http://www.cs.wustl.edu/~schmidt/ACE.html - -Running -------- - -See the "start" and "start.html" files for examples on how to run the -server and client applet, respectively. The "mywebaddress" variable is -the "temporary" URL of the server, and the "mywebdir" variable is the -temporary directory in which images are cached by the server. Make -sure that both these exist and are world-readable. The "mywebdir" -should be writable to by the server. The "mywebdir" and "mywebaddress" -variables should thus point to the same location, of which mywebdir -contains the path, and mywebaddress contains the URL. - -See "start" for an example on how to do this. - -If you only want to use an existing running server, all you need to -know is the server host-name and port number, and you can directly run -the start.html file via appletviewer. - -Notes ------ - -1. You can compile the client and server using the same makefile. -2. The client applet MUST reside on the same host as the server is running on. -4. run the server using start script. Change the paramters in the start script, - suitable to your configurations. The start script contains further - information on this. - - diff --git a/java/apps/NexusII/classes/ClientHandler.class b/java/apps/NexusII/classes/ClientHandler.class Binary files differdeleted file mode 100644 index c6bf722c54f..00000000000 --- a/java/apps/NexusII/classes/ClientHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/FrameHandler.class b/java/apps/NexusII/classes/FrameHandler.class Binary files differdeleted file mode 100644 index 72d0c67ce70..00000000000 --- a/java/apps/NexusII/classes/FrameHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/ImageCanvas.class b/java/apps/NexusII/classes/ImageCanvas.class Binary files differdeleted file mode 100644 index eefcfe0f323..00000000000 --- a/java/apps/NexusII/classes/ImageCanvas.class +++ /dev/null diff --git a/java/apps/NexusII/classes/NexusClientApplet.class b/java/apps/NexusII/classes/NexusClientApplet.class Binary files differdeleted file mode 100644 index 8157ac32759..00000000000 --- a/java/apps/NexusII/classes/NexusClientApplet.class +++ /dev/null diff --git a/java/apps/NexusII/classes/NexusIIserver.class b/java/apps/NexusII/classes/NexusIIserver.class Binary files differdeleted file mode 100644 index f8e566ce282..00000000000 --- a/java/apps/NexusII/classes/NexusIIserver.class +++ /dev/null diff --git a/java/apps/NexusII/classes/Room.class b/java/apps/NexusII/classes/Room.class Binary files differdeleted file mode 100644 index a9d0d4f97bb..00000000000 --- a/java/apps/NexusII/classes/Room.class +++ /dev/null diff --git a/java/apps/NexusII/classes/RoomFactory.class b/java/apps/NexusII/classes/RoomFactory.class Binary files differdeleted file mode 100644 index c1f92d83728..00000000000 --- a/java/apps/NexusII/classes/RoomFactory.class +++ /dev/null diff --git a/java/apps/NexusII/classes/RoomFrame.class b/java/apps/NexusII/classes/RoomFrame.class Binary files differdeleted file mode 100644 index 4b648e1a8cc..00000000000 --- a/java/apps/NexusII/classes/RoomFrame.class +++ /dev/null diff --git a/java/apps/NexusII/classes/RoomThread.class b/java/apps/NexusII/classes/RoomThread.class Binary files differdeleted file mode 100644 index 829fa4175cb..00000000000 --- a/java/apps/NexusII/classes/RoomThread.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CApplet.class b/java/apps/NexusII/classes/awtCommand/CApplet.class Binary files differdeleted file mode 100644 index 3af0361de76..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CApplet.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CApplet.java b/java/apps/NexusII/classes/awtCommand/CApplet.java deleted file mode 100644 index a8680d9abf3..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CApplet.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; -import java.applet.*; - -public class CApplet extends Applet { - - protected Command gotFocusCommand = null, - lostFocusCommand = null; - protected Command mouseDownCommand = null, - mouseDragCommand = null, - mouseEnterCommand = null, - mouseExitCommand = null, - mouseMoveCommand = null, - mouseUpCommand = null; - protected Command keyUpCommand = null, - keyDownCommand = null; - - /** - * Constructs a new CApplet. - */ - public CApplet() { - super(); - } - - /* - * event handling methods - */ - - /** - * Called if the window gains focus. This results in a call to - * the gotFocusCommand object with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the window loses focus. This results in a call to - * the lostFocusCommand object with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse is down. - * This results in a call to the mouseDownCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDown(Event evt, int x, int y) { - if (mouseDownCommand != null) - mouseDownCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is dragged. - * This results in a call to the mouseDragCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDrag(Event evt, int x, int y) { - if (mouseDragCommand != null) - mouseDragCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse enters the window. - * This results in a call to the mouseEnterCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseEnter(Event evt, int x, int y) { - if (mouseEnterCommand != null) - mouseEnterCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse moves inside the window. - * This results in a call to the mouseMoveCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseMove(Event evt, int x, int y) { - if (mouseExitCommand != null) - mouseExitCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is up. - * This results in a call to the mouseUpCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseUp(Event evt, int x, int y) { - if (mouseUpCommand != null) - mouseUpCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if a character is pressed. - * This results in a call to the keyDownCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyDown(Event evt, int key) { - if (keyDownCommand != null) - keyDownCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called if a character is released. - * This results in a call to the keyUpCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyUp(Event evt, int key) { - if (keyUpCommand != null) - keyUpCommand.execute(this, evt, new Integer(key)); - return false; - } - - - /* - * set...Command methods - */ - - - /** - * Sets the mouseDownCommand object. - */ - public void setMouseDownCommand(Command c) { - mouseDownCommand = c; - } - - /** - * Sets the moueDragCommand object. - */ - public void setMouseDragCommand(Command c) { - mouseDragCommand = c; - } - - /** - * Sets the mouseEnterCommand object. - */ - public void setMouseEnterCommand(Command c) { - mouseEnterCommand = c; - } - - /** - * Sets the mouseExitCommand object. - */ - public void setMouseExitCommand(Command c) { - mouseExitCommand = c; - } - - /** - * Sets the mouseMoveCommand object. - */ - public void setMouseMoveCommand(Command c) { - mouseMoveCommand = c; - } - - /** - * Sets the mouseUpCommand object. - */ - public void setMouseUpCommand(Command c) { - mouseUpCommand = c; - } - - /** - * Sets the keyDownCommand object. - */ - public void setKeyDownCommand(Command c) { - keyDownCommand = c; - } - - /** - * Sets the keyUpCommand object. - */ - public void setKeyUpCommand(Command c) { - keyUpCommand = c; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/CButton.class b/java/apps/NexusII/classes/awtCommand/CButton.class Binary files differdeleted file mode 100644 index b64fecd5bbf..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CButton.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CButton.java b/java/apps/NexusII/classes/awtCommand/CButton.java deleted file mode 100644 index ff0f3385bad..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CButton.java +++ /dev/null @@ -1,41 +0,0 @@ - -package awtCommand; - -import java.lang.*; -import java.awt.*; - -public class CButton extends java.awt.Button { - protected Command actionCommand = null; - - /** - * Constructs a CButton. - */ - public CButton() { - super(); - } - - /** - * Constructs a CButton with the given name. - */ - public CButton(String name) { - super(name); - } - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Called when the button is selected.. - * This results in a call to the actionCommand object - * with <code>what</code> set to the button's label. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/CCanvas.class b/java/apps/NexusII/classes/awtCommand/CCanvas.class Binary files differdeleted file mode 100644 index 5d697017b5b..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CCanvas.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CCanvas.java b/java/apps/NexusII/classes/awtCommand/CCanvas.java deleted file mode 100644 index 837b6f56f7a..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CCanvas.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CCanvas extends Canvas { - - protected Command gotFocusCommand = null, - lostFocusCommand = null; - protected Command mouseDownCommand = null, - mouseDragCommand = null, - mouseEnterCommand = null, - mouseExitCommand = null, - mouseMoveCommand = null, - mouseUpCommand = null; - protected Command keyUpCommand = null, - keyDownCommand = null; - protected Command actionCommand = null; - protected Command scrollAbsoluteCommand = null, - lineDownCommand = null, - lineUpCommand = null, - pageDownCommand = null, - pageUpCommand = null; - protected Command selectCommand = null, - deselectCommand = null; - - - /** - * Constructs a new CCanvas. - */ - public CCanvas() { - super(); - } - - /** - * Handles the event. - * Calls methods for variousL events and passes - * others to its superclass method. - */ - public boolean handleEvent(Event evt) { - switch (evt.id) { - case Event.SCROLL_ABSOLUTE: - return scrollAbsolute(evt, evt.arg); - case Event.SCROLL_LINE_DOWN: - return lineDown(evt, evt.arg); - case Event.SCROLL_LINE_UP: - return lineUp(evt, evt.arg); - case Event.SCROLL_PAGE_DOWN: - return pageDown(evt, evt.arg); - case Event.SCROLL_PAGE_UP: - return pageUp(evt, evt.arg); - case Event.LIST_SELECT: - return select(evt, evt.arg); - case Event.LIST_DESELECT: - return deselect(evt, evt.arg); - default: - return super.handleEvent(evt); - } - } - - - /* - * event handling methods - */ - - /** - * Called if the window gains focus. This results in a call to - * the gotFocusCommand object with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the window loses focus. This results in a call to - * the lostFocusCommand object with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse is down. - * This results in a call to the mouseDownCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDown(Event evt, int x, int y) { - if (mouseDownCommand != null) - mouseDownCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is dragged. - * This results in a call to the mouseDragCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDrag(Event evt, int x, int y) { - if (mouseDragCommand != null) - mouseDragCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse enters the window. - * This results in a call to the mouseEnterCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseEnter(Event evt, int x, int y) { - if (mouseEnterCommand != null) - mouseEnterCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse moves inside the window. - * This results in a call to the mouseMoveCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseMove(Event evt, int x, int y) { - if (mouseExitCommand != null) - mouseExitCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is up. - * This results in a call to the mouseUpCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseUp(Event evt, int x, int y) { - if (mouseUpCommand != null) - mouseUpCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if a character is pressed. - * This results in a call to the keyDownCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyDown(Event evt, int key) { - if (keyDownCommand != null) - keyDownCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called if a character is released. - * This results in a call to the keyUpCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyUp(Event evt, int key) { - if (keyUpCommand != null) - keyUpCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called when an ACTION_EVENT is generated. - * This results in a call to the actionCommand object - * with <code>what</code> set to the event's arg. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is dragged. - * This results in a call to the scrollAbsoluteCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean scrollAbsolute(Event evt, Object what) { - if (scrollAbsoluteCommand != null) - scrollAbsoluteCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented down. - * This results in a call to the lineDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineDown(Event evt, Object what) { - if (lineDownCommand != null) - lineDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented up. - * This results in a call to the lineUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineUp(Event evt, Object what) { - if (lineUpCommand != null) - lineUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages up. - * This results in a call to the pageUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageUp(Event evt, Object what) { - if (pageUpCommand != null) - pageUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages down. - * This results in a call to the pageDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageDown(Event evt, Object what) { - if (pageDownCommand != null) - pageDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse selects an item in a List. - * This results in a call to the selectCommand object - * with <code>what</code> set to the selected index. - */ - public boolean select(Event evt, Object what) { - if (selectCommand != null) - selectCommand.execute(this, evt, what); - return false; - } - - - /** - * Called if the mouse deselects an item in a List. - * This results in a call to the deselectCommand object - * with <code>what</code> set to the deselected index. - */ - public boolean deselect(Event evt, Object what) { - if (deselectCommand != null) - deselectCommand.execute(this, evt, what); - return false; - } - - - /* - * set...Command methods - */ - - - - /** - * Sets the mouseDownCommand object. - */ - public void setMouseDownCommand(Command c) { - mouseDownCommand = c; - } - - /** - * Sets the moueDragCommand object. - */ - public void setMouseDragCommand(Command c) { - mouseDragCommand = c; - } - - /** - * Sets the mouseEnterCommand object. - */ - public void setMouseEnterCommand(Command c) { - mouseEnterCommand = c; - } - - /** - * Sets the mouseExitCommand object. - */ - public void setMouseExitCommand(Command c) { - mouseExitCommand = c; - } - - /** - * Sets the mouseMoveCommand object. - */ - public void setMouseMoveCommand(Command c) { - mouseMoveCommand = c; - } - - /** - * Sets the mouseUpCommand object. - */ - public void setMouseUpCommand(Command c) { - mouseUpCommand = c; - } - - /** - * Sets the keyDownCommand object. - */ - public void setKeyDownCommand(Command c) { - keyDownCommand = c; - } - - /** - * Sets the keyUpCommand object. - */ - public void setKeyUpCommand(Command c) { - keyUpCommand = c; - } - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Sets the scrollAbsoluteCommand. - */ - public void setScrollAbsoluteCommand(Command c) { - scrollAbsoluteCommand = c; - } - - /** - * Sets the lineUpCommand. - */ - public void setLineUpCommand(Command c) { - lineUpCommand = c; - } - - /** - * Sets the lineDownCommand. - */ - public void setLineDownCommand(Command c) { - lineDownCommand = c; - } - - /** - * Sets the pageUpCommand. - */ - public void setPageUpCommand(Command c) { - pageUpCommand = c; - } - - /** - * Sets the pageDownCommand. - */ - public void setPageDownCommand(Command c) { - pageDownCommand = c; - } - - /** - * Sets the selectCommand. - */ - public void setSelectCommand(Command select) { - selectCommand = select; - } - - /** - * Sets the deselectCommand. - */ - public void setDeselectCommand(Command deselect) { - deselectCommand = deselect; - } - -} diff --git a/java/apps/NexusII/classes/awtCommand/CFrame.class b/java/apps/NexusII/classes/awtCommand/CFrame.class Binary files differdeleted file mode 100644 index 66f25773c76..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CFrame.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CFrame.java b/java/apps/NexusII/classes/awtCommand/CFrame.java deleted file mode 100644 index f63d3ce8b9a..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CFrame.java +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CFrame extends Frame { - - protected Command destroyCommand = null, - deiconifyCommand = null, - iconifyCommand = null, - movedCommand = null; - protected Command gotFocusCommand = null, - lostFocusCommand = null; - protected Command mouseDownCommand = null, - mouseDragCommand = null, - mouseEnterCommand = null, - mouseExitCommand = null, - mouseMoveCommand = null, - mouseUpCommand = null; - protected Command keyUpCommand = null, - keyDownCommand = null; - protected Command actionCommand = null; - protected Command scrollAbsoluteCommand = null, - lineDownCommand = null, - lineUpCommand = null, - pageDownCommand = null, - pageUpCommand = null; - protected Command selectCommand = null, - deselectCommand = null; - - /** - * Constructs a new, initially invisible CFrame. - */ - public CFrame() { - super(); - } - - /** - * Constructs a new, initially invisible CFrame with the - * specified title. - */ - public CFrame(String title) { - super(title); - } - - /** - * Handles the event - */ - public boolean handleEvent(Event evt) { - switch (evt.id) { - case Event.WINDOW_DESTROY: - return windowDestroy(evt); - case Event.WINDOW_DEICONIFY: - return windowDeiconify(evt); - case Event.WINDOW_ICONIFY: - return windowIconify(evt); - case Event.WINDOW_MOVED: - return windowMoved(evt); - case Event.SCROLL_ABSOLUTE: - return scrollAbsolute(evt, evt.arg); - case Event.SCROLL_LINE_DOWN: - return lineDown(evt, evt.arg); - case Event.SCROLL_LINE_UP: - return lineUp(evt, evt.arg); - case Event.SCROLL_PAGE_DOWN: - return pageDown(evt, evt.arg); - case Event.SCROLL_PAGE_UP: - return pageUp(evt, evt.arg); - case Event.LIST_SELECT: - return select(evt, evt.arg); - case Event.LIST_DESELECT: - return deselect(evt, evt.arg); - default: - return super.handleEvent(evt); - } - } - - /* - * event handling methods - */ - - /** - * Called if the dialog's window is destroyed. This results in a call to - * the destroyCommand object with <code>what</code> set to null - */ - public boolean windowDestroy(Event evt) { - if (destroyCommand != null) - destroyCommand.execute(this, evt, null); - return false; - } - - /** - * Called if the dialog's window is deiconified. This results in a call to - * the deiconifyCommand object with <code>what</code> set to null - */ - public boolean windowDeiconify(Event evt) { - if (deiconifyCommand != null) - deiconifyCommand.execute(this, evt, null); - return false; - } - - /** - * Called if the dialog is iconified. This results in a call to - * the iconifyCommand object with <code>what</code> set to null - */ - public boolean windowIconify(Event evt) { - if (iconifyCommand != null) - iconifyCommand.execute(this, evt, null); - return false; - } - - /** - * Called if the dialog's window is moved. This results in a call to - * the movedCommand object with <code>what</code> set to Point(x, y) - */ - public boolean windowMoved(Event evt) { - if (movedCommand != null) - movedCommand.execute(this, evt, new Point(evt.x, evt.y)); - return false; - } - - /* - * I don't know where what objects this next set should belong - * to. Putting them at the top is ok for now - */ - - /** - * Called if the window gains focus. This results in a call to - * the gotFocusCommand object with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the window loses focus. This results in a call to - * the lostFocusCommand object with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse is down. - * This results in a call to the mouseDownCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDown(Event evt, int x, int y) { - if (mouseDownCommand != null) - mouseDownCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is dragged. - * This results in a call to the mouseDragCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDrag(Event evt, int x, int y) { - if (mouseDragCommand != null) - mouseDragCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse enters the window. - * This results in a call to the mouseEnterCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseEnter(Event evt, int x, int y) { - if (mouseEnterCommand != null) - mouseEnterCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse moves inside the window. - * This results in a call to the mouseMoveCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseMove(Event evt, int x, int y) { - if (mouseExitCommand != null) - mouseExitCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is up. - * This results in a call to the mouseUpCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseUp(Event evt, int x, int y) { - if (mouseUpCommand != null) - mouseUpCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if a character is pressed. - * This results in a call to the keyDownCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyDown(Event evt, int key) { - if (keyDownCommand != null) - keyDownCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called if a character is released. - * This results in a call to the keyUpCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyUp(Event evt, int key) { - if (keyUpCommand != null) - keyUpCommand.execute(this, evt, new Integer(key)); - return false; - } - - - /** - * Called when an ACTION_EVENT is generated. - * This results in a call to the actionCommand object - * with <code>what</code> set to the event's arg. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is dragged. - * This results in a call to the scrollAbsoluteCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean scrollAbsolute(Event evt, Object what) { - if (scrollAbsoluteCommand != null) - scrollAbsoluteCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented down. - * This results in a call to the lineDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineDown(Event evt, Object what) { - if (lineDownCommand != null) - lineDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented up. - * This results in a call to the lineUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineUp(Event evt, Object what) { - if (lineUpCommand != null) - lineUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages up. - * This results in a call to the pageUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageUp(Event evt, Object what) { - if (pageUpCommand != null) - pageUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages down. - * This results in a call to the pageDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageDown(Event evt, Object what) { - if (pageDownCommand != null) - pageDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse selects an item in a List. - * This results in a call to the selectCommand object - * with <code>what</code> set to the selected index. - */ - public boolean select(Event evt, Object what) { - if (selectCommand != null) - selectCommand.execute(this, evt, what); - return false; - } - - - /** - * Called if the mouse deselects an item in a List. - * This results in a call to the deselectCommand object - * with <code>what</code> set to the deselected index. - */ - public boolean deselect(Event evt, Object what) { - if (deselectCommand != null) - deselectCommand.execute(this, evt, what); - return false; - } - - - /* - * set...Command methods - */ - - - /** - * Sets the destroyCommand object. - */ - public void setDestroyCommand(Command c) { - destroyCommand = c; - } - - /** - * Sets the deiconifyCommand object. - */ - public void setDeiconifyCommand(Command c) { - deiconifyCommand = c; - } - - /** - * Sets the iconifyCommand object. - */ - public void setIconifyCommand(Command c) { - iconifyCommand = c; - } - - /** - * Sets the movedCommand object. - */ - public void setMovedCommand(Command c) { - movedCommand = c; - } - - /** - * Sets the mouseDownCommand object. - */ - public void setMouseDownCommand(Command c) { - mouseDownCommand = c; - } - - /** - * Sets the moueDragCommand object. - */ - public void setMouseDragCommand(Command c) { - mouseDragCommand = c; - } - - /** - * Sets the mouseEnterCommand object. - */ - public void setMouseEnterCommand(Command c) { - mouseEnterCommand = c; - } - - /** - * Sets the mouseExitCommand object. - */ - public void setMouseExitCommand(Command c) { - mouseExitCommand = c; - } - - /** - * Sets the mouseMoveCommand object. - */ - public void setMouseMoveCommand(Command c) { - mouseMoveCommand = c; - } - - /** - * Sets the mouseUpCommand object. - */ - public void setMouseUpCommand(Command c) { - mouseUpCommand = c; - } - - /** - * Sets the keyDownCommand object. - */ - public void setKeyDownCommand(Command c) { - keyDownCommand = c; - } - - /** - * Sets the keyUpCommand object. - */ - public void setKeyUpCommand(Command c) { - keyUpCommand = c; - } - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Sets the scrollAbsoluteCommand. - */ - public void setScrollAbsoluteCommand(Command c) { - scrollAbsoluteCommand = c; - } - - /** - * Sets the lineUpCommand. - */ - public void setLineUpCommand(Command c) { - lineUpCommand = c; - } - - /** - * Sets the lineDownCommand. - */ - public void setLineDownCommand(Command c) { - lineDownCommand = c; - } - - /** - * Sets the pageUpCommand. - */ - public void setPageUpCommand(Command c) { - pageUpCommand = c; - } - - /** - * Sets the pageDownCommand. - */ - public void setPageDownCommand(Command c) { - pageDownCommand = c; - } - - /** - * Sets the selectCommand. - */ - public void setSelectCommand(Command select) { - selectCommand = select; - } - - public void setGotFocusCommand(Command c) { - gotFocusCommand = c ; - } - /** - * Sets the deselectCommand. - */ - public void setDeselectCommand(Command deselect) { - deselectCommand = deselect; - } - -} - - - - - - - - - - - - - diff --git a/java/apps/NexusII/classes/awtCommand/CList.class b/java/apps/NexusII/classes/awtCommand/CList.class Binary files differdeleted file mode 100644 index c595ce7786b..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CList.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CList.java b/java/apps/NexusII/classes/awtCommand/CList.java deleted file mode 100644 index 110e6a01db2..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CList.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - - -package awtCommand; - -import java.awt.*; - -public class CList extends List { - protected Command selectCommand = null; - protected Command deselectCommand = null; - protected Command actionCommand = null; - - /** - * Handles the event - */ - public boolean handleEvent(Event evt) { - switch (evt.id) { - case Event.LIST_SELECT: - return select(evt, evt.arg); - case Event.LIST_DESELECT: - return deselect(evt, evt.arg); - default: - return super.handleEvent(evt); - } - } - - /* - * event handling methods - */ - - - /** - * Called if the Enter key is pressed. - * This results in a call to the actionCommand object - * with <code>what</code> set to the selected item. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse selects an item. - * This results in a call to the selectCommand object - * with <code>what</code> set to the selected index. - */ - public boolean select(Event evt, Object what) { - if (selectCommand != null) - selectCommand.execute(this, evt, what); - return false; - } - - - /** - * Called if the mouse deselects an item. - * This results in a call to the deselectCommand object - * with <code>what</code> set to the deselected index. - */ - public boolean deselect(Event evt, Object what) { - if (deselectCommand != null) - deselectCommand.execute(this, evt, what); - return false; - } - - - /** - * Sets the actionCommand. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Sets the selectCommand. - */ - public void setSelectCommand(Command select) { - selectCommand = select; - } - - /** - * Sets the deselectCommand. - */ - public void setDeselectCommand(Command deselect) { - deselectCommand = deselect; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/CPanel.class b/java/apps/NexusII/classes/awtCommand/CPanel.class Binary files differdeleted file mode 100644 index d00477a30f5..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CPanel.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CPanel.java b/java/apps/NexusII/classes/awtCommand/CPanel.java deleted file mode 100644 index 1c8d39f8537..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CPanel.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CPanel extends Panel { - - protected Command gotFocusCommand = null, - lostFocusCommand = null; - protected Command mouseDownCommand = null, - mouseDragCommand = null, - mouseEnterCommand = null, - mouseExitCommand = null, - mouseMoveCommand = null, - mouseUpCommand = null; - protected Command keyUpCommand = null, - keyDownCommand = null; - protected Command actionCommand = null; - protected Command scrollAbsoluteCommand = null, - lineDownCommand = null, - lineUpCommand = null, - pageDownCommand = null, - pageUpCommand = null; - protected Command selectCommand = null, - deselectCommand = null; - - /** - * Constructs a new CPanel. - */ - public CPanel() { - super(); - } - - - /** - * Handles the event. - * Calls methods for variousL events and passes - * others to its superclass method. - */ - public boolean handleEvent(Event evt) { - switch (evt.id) { - case Event.SCROLL_ABSOLUTE: - return scrollAbsolute(evt, evt.arg); - case Event.SCROLL_LINE_DOWN: - return lineDown(evt, evt.arg); - case Event.SCROLL_LINE_UP: - return lineUp(evt, evt.arg); - case Event.SCROLL_PAGE_DOWN: - return pageDown(evt, evt.arg); - case Event.SCROLL_PAGE_UP: - return pageUp(evt, evt.arg); - case Event.LIST_SELECT: - return select(evt, evt.arg); - case Event.LIST_DESELECT: - return deselect(evt, evt.arg); - default: - return super.handleEvent(evt); - } - } - - /* - * event handling methods - */ - - /** - * Called if the window gains focus. This results in a call to - * the gotFocusCommand object with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the window loses focus. This results in a call to - * the lostFocusCommand object with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse is down. - * This results in a call to the mouseDownCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDown(Event evt, int x, int y) { - if (mouseDownCommand != null) - mouseDownCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is dragged. - * This results in a call to the mouseDragCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseDrag(Event evt, int x, int y) { - if (mouseDragCommand != null) - mouseDragCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse enters the window. - * This results in a call to the mouseEnterCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseEnter(Event evt, int x, int y) { - if (mouseEnterCommand != null) - mouseEnterCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse moves inside the window. - * This results in a call to the mouseMoveCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseMove(Event evt, int x, int y) { - if (mouseExitCommand != null) - mouseExitCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if the mouse is up. - * This results in a call to the mouseUpCommand object with - * <code>what</code> set to Point(x, y) - */ - public boolean mouseUp(Event evt, int x, int y) { - if (mouseUpCommand != null) - mouseUpCommand.execute(this, evt, new Point(x, y)); - return false; - } - - /** - * Called if a character is pressed. - * This results in a call to the keyDownCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyDown(Event evt, int key) { - if (keyDownCommand != null) - keyDownCommand.execute(this, evt, new Integer(key)); - return false; - } - - /** - * Called if a character is released. - * This results in a call to the keyUpCommand object with - * <code>what</code> set to Integer(key). - */ - public boolean keyUp(Event evt, int key) { - if (keyUpCommand != null) - keyUpCommand.execute(this, evt, new Integer(key)); - return false; - } - - - /** - * Called when an ACTION_EVENT is generated. - * This results in a call to the actionCommand object - * with <code>what</code> set to the event's arg. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is dragged. - * This results in a call to the scrollAbsoluteCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean scrollAbsolute(Event evt, Object what) { - if (scrollAbsoluteCommand != null) - scrollAbsoluteCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented down. - * This results in a call to the lineDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineDown(Event evt, Object what) { - if (lineDownCommand != null) - lineDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar is incremented up. - * This results in a call to the lineUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean lineUp(Event evt, Object what) { - if (lineUpCommand != null) - lineUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages up. - * This results in a call to the pageUpCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageUp(Event evt, Object what) { - if (pageUpCommand != null) - pageUpCommand.execute(this, evt, what); - return false; - } - - /** - * Called when a scrollbar pages down. - * This results in a call to the pageDownCommand object - * with <code>what</code> set to the slider location value. - */ - public boolean pageDown(Event evt, Object what) { - if (pageDownCommand != null) - pageDownCommand.execute(this, evt, what); - return false; - } - - /** - * Called if the mouse selects an item in a List. - * This results in a call to the selectCommand object - * with <code>what</code> set to the selected index. - */ - public boolean select(Event evt, Object what) { - if (selectCommand != null) - selectCommand.execute(this, evt, what); - return false; - } - - - /** - * Called if the mouse deselects an item in a List. - * This results in a call to the deselectCommand object - * with <code>what</code> set to the deselected index. - */ - public boolean deselect(Event evt, Object what) { - if (deselectCommand != null) - deselectCommand.execute(this, evt, what); - return false; - } - - /* - * set...Command methods - */ - - - - /** - * Sets the mouseDownCommand object. - */ - public void setMouseDownCommand(Command c) { - mouseDownCommand = c; - } - - /** - * Sets the moueDragCommand object. - */ - public void setMouseDragCommand(Command c) { - mouseDragCommand = c; - } - - /** - * Sets the mouseEnterCommand object. - */ - public void setMouseEnterCommand(Command c) { - mouseEnterCommand = c; - } - - /** - * Sets the mouseExitCommand object. - */ - public void setMouseExitCommand(Command c) { - mouseExitCommand = c; - } - - /** - * Sets the mouseMoveCommand object. - */ - public void setMouseMoveCommand(Command c) { - mouseMoveCommand = c; - } - - /** - * Sets the mouseUpCommand object. - */ - public void setMouseUpCommand(Command c) { - mouseUpCommand = c; - } - - /** - * Sets the keyDownCommand object. - */ - public void setKeyDownCommand(Command c) { - keyDownCommand = c; - } - - /** - * Sets the keyUpCommand object. - */ - public void setKeyUpCommand(Command c) { - keyUpCommand = c; - } - - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command action) { - actionCommand = action; - } - - /** - * Sets the scrollAbsoluteCommand. - */ - public void setScrollAbsoluteCommand(Command c) { - scrollAbsoluteCommand = c; - } - - /** - * Sets the lineUpCommand. - */ - public void setLineUpCommand(Command c) { - lineUpCommand = c; - } - - /** - * Sets the lineDownCommand. - */ - public void setLineDownCommand(Command c) { - lineDownCommand = c; - } - - /** - * Sets the pageUpCommand. - */ - public void setPageUpCommand(Command c) { - pageUpCommand = c; - } - - /** - * Sets the pageDownCommand. - */ - public void setPageDownCommand(Command c) { - pageDownCommand = c; - } - - /** - * Sets the selectCommand. - */ - public void setSelectCommand(Command select) { - selectCommand = select; - } - - /** - * Sets the deselectCommand. - */ - public void setDeselectCommand(Command deselect) { - deselectCommand = deselect; - } - -} diff --git a/java/apps/NexusII/classes/awtCommand/CTextArea.class b/java/apps/NexusII/classes/awtCommand/CTextArea.class Binary files differdeleted file mode 100644 index 9ec6e238cdf..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CTextArea.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CTextArea.java b/java/apps/NexusII/classes/awtCommand/CTextArea.java deleted file mode 100644 index eacaf526929..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CTextArea.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CTextArea extends TextArea { - - protected Command gotFocusCommand = null, - lostFocusCommand = null; - - /** - * Constructs a new TextArea. - */ - public CTextArea() { - super(); - } - - /** - * Constructs a new TextArea with the specified number of rows and columns. - * @param rows the number of rows - * @param cols the number of columns - */ - public CTextArea(int rows, int cols) { - super(rows, cols); - } - - /** - * Constructs a new TextArea with the specified text displayed. - * @param text the text to be displayed - */ - public CTextArea(String text) { - super(text); - } - - /** - * Constructs a new TextArea with the specified text and the - * specified number of rows - * and columns. - * @param text the text to be displayed - * @param rows the number of rows - * @param cols the number of cols - */ - public CTextArea(String text, int rows, int cols) { - super(text, rows, cols); - } - - - /** - * Called when the text area gains the focus. - * This results in a call to the gotFocusCommand object - * with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called when the text area loses the focus. - * This results in a call to the lostFocusCommand object - * with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Sets the gotFocusCommand object. - */ - public void setGotFocusCommand(Command c) { - gotFocusCommand = c; - } - - /** - * Sets the lostFocusCommand object. - */ - public void setLostFocusCommand(Command c) { - lostFocusCommand = c; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/CTextField.class b/java/apps/NexusII/classes/awtCommand/CTextField.class Binary files differdeleted file mode 100644 index 6f298a43348..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CTextField.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/CTextField.java b/java/apps/NexusII/classes/awtCommand/CTextField.java deleted file mode 100644 index 146f13206e5..00000000000 --- a/java/apps/NexusII/classes/awtCommand/CTextField.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -package awtCommand; - -import java.awt.*; - -public class CTextField extends TextField { - - protected Command actionCommand = null, - gotFocusCommand = null, - lostFocusCommand = null; - - /** - * Constructs a new CTextField. - */ - public CTextField() { - super(); - } - - /** - * Constructs a new CTextField initialized with the specified columns. - * @param cols the number of columns - */ - public CTextField(int cols) { - super(cols); - } - - /** - * Constructs a new CTextField initialized with the specified text. - * @param text the text to be displayed - */ - public CTextField(String text) { - super(text); - } - - - /** - * Constructs a new CTextField initialized with the specified text and columns. - * @param text the text to be displayed - * @param cols the number of columns - */ - public CTextField(String text, int cols) { - super(text, cols); - } - - - /** - * Called when Enter is pressed in the text field. - * This results in a call to the actionCommand object - * with <code>what</code> set to the text contents. - */ - public boolean action(Event evt, Object what) { - if (actionCommand != null) - actionCommand.execute(this, evt, what); - return false; - } - - /** - * Called when the text field gains the focus. - * This results in a call to the gotFocusCommand object - * with <code>what</code> set to null. - */ - public boolean gotFocus(Event evt, Object what) { - if (gotFocusCommand != null) - gotFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Called when the text field loses the focus. - * This results in a call to the lostFocusCommand object - * with <code>what</code> set to null. - */ - public boolean lostFocus(Event evt, Object what) { - if (lostFocusCommand != null) - lostFocusCommand.execute(this, evt, what); - return false; - } - - /** - * Sets the actionCommand object. - */ - public void setActionCommand(Command c) { - actionCommand = c; - } - - - /** - * Sets the gotFocusCommand object. - */ - public void setGotFocusCommand(Command c) { - gotFocusCommand = c; - } - - /** - * Sets the lostFocusCommand object. - */ - public void setLostFocusCommand(Command c) { - lostFocusCommand = c; - } -} diff --git a/java/apps/NexusII/classes/awtCommand/Command.class b/java/apps/NexusII/classes/awtCommand/Command.class Binary files differdeleted file mode 100644 index 6b3c12c24f7..00000000000 --- a/java/apps/NexusII/classes/awtCommand/Command.class +++ /dev/null diff --git a/java/apps/NexusII/classes/awtCommand/Command.java b/java/apps/NexusII/classes/awtCommand/Command.java deleted file mode 100644 index 373c7a363cf..00000000000 --- a/java/apps/NexusII/classes/awtCommand/Command.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 1996 Jan Newmarch, University of Canberra. - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The author - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - - - -package awtCommand; - -import java.awt.*; - -public interface Command { - - /** - * Executes application logic. - * Called by events occurring in associated objects - */ - public abstract void execute(Object target, Event evt, Object what); -} diff --git a/java/apps/NexusII/classes/commandHandler.class b/java/apps/NexusII/classes/commandHandler.class Binary files differdeleted file mode 100644 index 53033fb6b6b..00000000000 --- a/java/apps/NexusII/classes/commandHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/commandParser.class b/java/apps/NexusII/classes/commandParser.class Binary files differdeleted file mode 100644 index 62da40871e6..00000000000 --- a/java/apps/NexusII/classes/commandParser.class +++ /dev/null diff --git a/java/apps/NexusII/classes/connectionHandler.class b/java/apps/NexusII/classes/connectionHandler.class Binary files differdeleted file mode 100644 index 8708229c0eb..00000000000 --- a/java/apps/NexusII/classes/connectionHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/joinHandler.class b/java/apps/NexusII/classes/joinHandler.class Binary files differdeleted file mode 100644 index 7669e7faed7..00000000000 --- a/java/apps/NexusII/classes/joinHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/roomHandler.class b/java/apps/NexusII/classes/roomHandler.class Binary files differdeleted file mode 100644 index 9eaa6cc0899..00000000000 --- a/java/apps/NexusII/classes/roomHandler.class +++ /dev/null diff --git a/java/apps/NexusII/classes/textHandler.class b/java/apps/NexusII/classes/textHandler.class Binary files differdeleted file mode 100644 index c52764a236b..00000000000 --- a/java/apps/NexusII/classes/textHandler.class +++ /dev/null diff --git a/java/apps/NexusII/src/Consumer.java b/java/apps/NexusII/src/Consumer.java deleted file mode 100644 index 84df9b3a3ae..00000000000 --- a/java/apps/NexusII/src/Consumer.java +++ /dev/null @@ -1,74 +0,0 @@ - -// This class encapsulates a Consumer. The consumer dq's from the queue -// Supports both a timed and blocking consumer. -// Each instance of this class creates a different thread of control. -// On timeout, the producer returns. -// The producer tries to dq "iteration" number of times, unless it times out - -//package NexusII.util ; - -public class Consumer extends Thread -{ -public static final int DEFAULT_ITERATIONS = 1 ; -public Consumer(MT_Bounded_Queue queue) - { - this.queue_ = queue ; - this.iterations_ = new Integer(DEFAULT_ITERATIONS); - this.time_out_ = -1 ; - } - -public Consumer(MT_Bounded_Queue queue, String name) - { - super(name); - this.queue_ = queue ; - this.iterations_ = new Integer(DEFAULT_ITERATIONS); - this.time_out_ = -1 ; - } - - -public Consumer(MT_Bounded_Queue queue, String name, Integer iterations) - { - super(name); - this.queue_ = queue ; - this.iterations_ = iterations ; - this.time_out_ = -1 ; - } - - -public Consumer(MT_Bounded_Queue queue, String name, Integer iterations, long msec_timeout) - { - super(name); - this.queue_ = queue ; - this.iterations_ = iterations ; - this.time_out_ = msec_timeout ; - } - - - -public void run() - { - for(int i=0;i<iterations_.intValue();i++) - { - if(time_out_ < 0) - System.out.println(getName() + ": dequeued " + queue_.dq()); - else - { - Object err = queue_.dq(time_out_); - if(err == null) - { - System.out.println(getName() + ": Timedout\n"); - return ; - } - - else - System.out.println(getName() + ": dequeued " + err); - } - } - } - - -protected MT_Bounded_Queue queue_ ; -private Integer iterations_ ; -private long time_out_ ; -} - diff --git a/java/apps/NexusII/src/MT_Bounded_Queue.java b/java/apps/NexusII/src/MT_Bounded_Queue.java deleted file mode 100644 index a9b493fa263..00000000000 --- a/java/apps/NexusII/src/MT_Bounded_Queue.java +++ /dev/null @@ -1,226 +0,0 @@ - -// package NexusII.util ; - -// The minimun functionality to be associated with a queue -interface Queue -{ -public void nq(Object item); -public Object dq(); -public boolean is_full(); -public boolean is_empty(); -public static final int DEF_SIZE = 1; -}; - -// Specific Conditions associated with MT_Bounded_Queue -// Is true if there is space in the queue - -class Not_Full_Condition extends Timed_Wait -{ - -public Not_Full_Condition(MT_Bounded_Queue q) - { - super(q); - } - -public synchronized boolean condition() - { - MT_Bounded_Queue mq_ = (MT_Bounded_Queue) object_; - return !mq_.is_full (); - } - -} - -// Is true if there's something in the queue - -class Not_Empty_Condition extends Timed_Wait -{ - -public Not_Empty_Condition(MT_Bounded_Queue q) - { - super(q); - } - -public synchronized boolean condition() - { - // Delegate to the appropriate conditional - // check on the MessageQueue. - MT_Bounded_Queue mq_ = (MT_Bounded_Queue) object_; - return !mq_.is_empty (); - } - -private MT_Bounded_Queue mq_ ; -} - - - - -// Encapsulates a bounded - synchronized queue - -public class MT_Bounded_Queue implements Queue -{ - - -private Object[] queue_ ; -private int front_ ; -private int back_ ; -private int max_size_ ; -private int size_ ; -private Not_Empty_Condition not_empty_condition_ ; -private Not_Full_Condition not_full_condition_ ; -private int nq_count_ ; -private int dq_count_ ; - -// The counters counts the number of nq's and dq's operations made on this -// instance of the queue - -public int dq_count() -{ - return dq_count_ ; -} - -public int nq_count() -{ - return nq_count_ ; -} - -public MT_Bounded_Queue() - { - // call the other constructor with DEF_SIZE - this(DEF_SIZE); - } - -public MT_Bounded_Queue(int max_size) - { - this.front_ = 0 ; - this.back_ = 0 ; - this.max_size_ = max_size ; - this.size_ = 0 ; - // these are included for STATISTICS - this.nq_count_ = 0 ; - this.dq_count_ = 0 ; - this.queue_ = new Object[this.max_size_]; - not_full_condition_ = new Not_Full_Condition(this); - not_empty_condition_ = new Not_Empty_Condition(this); - } - -// Blocking nq -public synchronized void nq(Object item) - { - // Wait till the queue has space - while(is_full()) - { - try { - wait(); - } catch (InterruptedException e) {} - } - - // enqueue here - queue_[back_] = item ; - back_ = (back_ + 1) % max_size_ ; - size_++ ; - // One more enqueue operation has occured - nq_count_ ++ ; - // wakeup the sleeping guys - notifyAll(); - } - - // Timed nq -// returns -1 if timed_out -public synchronized int nq(Object item,long msec_timeout) - { - // Wait till the queue has space - try { - not_full_condition_.timed_wait(msec_timeout); - } catch (InterruptedException e) {} - catch (TimeoutException t) - { - return -1 ; - } - - // enqueue here - queue_[back_] = item ; - back_ = (back_ + 1) % max_size_ ; - size_++ ; - - // One more enqueue operation has occured - nq_count_ ++ ; - // wakeup the sleeping consumers - not_empty_condition_.broadcast (); - return 0 ; - } - - - - - // Blockin dq -public synchronized Object dq() - { - // wait till the queue has something in it - while(is_empty()) - { - try { - wait(); - } catch (InterruptedException e) {} - } - - // dequeue here - Object return_object = queue_[front_] ; - front_ = (front_ + 1) % max_size_ ; - size_ -- ; - // One more enqueue operation has occured - dq_count_ ++ ; - //wake up the sleeping producers - notifyAll(); - return return_object ; - } - - - // Timed dq - -public synchronized Object dq(long msec_timeout) - { - // wait till the queue has something in it - try { - not_empty_condition_.timed_wait(msec_timeout); - } catch (InterruptedException e) {} - catch (TimeoutException t) - { - return null; - } - - // dequeue here - Object return_object = queue_[front_] ; - front_ = (front_ + 1) % max_size_ ; - size_ -- ; - - // One more enqueue operation has occured - dq_count_ ++ ; - - //wake up the sleeping guys - not_full_condition_.broadcast(); - return return_object ; - } - -public boolean is_empty() - { - if (size_ == 0) - return true ; - else - return false ; - - } - -public boolean is_full() - { - if (size_ == max_size_) - return true ; - else - return false ; - } - -} - - - - - diff --git a/java/apps/NexusII/src/MT_Bounded_Queue_Group.java b/java/apps/NexusII/src/MT_Bounded_Queue_Group.java deleted file mode 100644 index 734dc51a84b..00000000000 --- a/java/apps/NexusII/src/MT_Bounded_Queue_Group.java +++ /dev/null @@ -1,79 +0,0 @@ -//package NexusII.server; - -//import NexusII.util.*; -import java.util.*; - - -public class MT_Bounded_Queue_Group { - - public Vector q_group_ = new Vector(); - - public MT_Bounded_Queue_Group(int num) { - - q_group_ = new Vector(num); - - } - - public MT_Bounded_Queue_Group() { - - // q_group_ = new Vector(); - - } - - public String toString() { - - return q_group_.toString(); - - } - - // always returns true - public boolean addToGroup(MT_Bounded_Queue q) { - - q_group_.addElement(q); - return true; // for now - - } - - - // returns false if the q was not part of the group - public boolean delFromGroup(MT_Bounded_Queue q) { - - return q_group_.removeElement(q); - - } - - - public boolean checkInGroup(MT_Bounded_Queue q) { - - return q_group_.contains(q); - - } - - - // returns number of q's on which data was successfully enqueued - public int nq(Object o) { - - if(q_group_.isEmpty() ) - return 0; - - Enumeration e = q_group_.elements(); - - int i = 0; - while(e.hasMoreElements()) { - - MT_Bounded_Queue q = (MT_Bounded_Queue) e.nextElement(); - q.nq(o); - i++; - - } - - return i; - } - -} - - - - - - diff --git a/java/apps/NexusII/src/NexusClientApplet.java b/java/apps/NexusII/src/NexusClientApplet.java deleted file mode 100644 index 58b26930718..00000000000 --- a/java/apps/NexusII/src/NexusClientApplet.java +++ /dev/null @@ -1,494 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:10:59 sumedh - Added the Nexus II source code files. - -# Revision 1.3 1996/12/06 07:25:29 rajeev -# Got SetRoomName to work -- needed for LROOMS -# -# Revision 1.2 1996/12/06 04:48:21 rajeev -# added handling for l_users and L_room packets from server -# -# Revision 1.1 1996/12/06 03:37:22 rajeev -# Initial revision -# - - This is the client applet - Part of Nexus-II project !! - Copyright : Aravind Gopalan, Rajeev Bector, Sumedh Mungee -*/ - -// package NexusII; - -// I hate packages - -import java.applet.Applet; -import java.awt.* ; -import java.io.*; -import java.net.*; -import java.util.*; - -//import NexusII.networking.* ; -//import NexusII.client.* ; -//import NexusII.util.* ; - -// get the awtCommand package now -import awtCommand.* ; - -// The applet runs the root thread -- easy access to graphics now ... - -public class NexusClientApplet extends CApplet implements consts,Runnable { - - // Who am I -- will be modified if the /nick command is given - public static String myName = new String("anonymous"); - - /* All Event Handlers */ - - // To check if applet is connected - boolean connected = false; - - // The connector handler - connectionHandler nexusConnector ; - - // join handler - joinHandler nexusJoiner ; - - // command handler - commandParser nexusParser ; - - commandHandler commandLineHandler ; - // Streams for writing and reading from Socket - DataOutputStream outStream; - DataInputStream inStream; - - // Thread which does everything for the applet - Thread mainThread ; - - // this is just a visit - // host where I live actually ;-) - String host; - - // Which server to connect to - Integer serverPort ; - - // Where are the queues for reading and writing - // reader and writers will access these and also the interpretor and dep. - - MT_Bounded_Queue read_q ; - MT_Bounded_Queue write_q ; - MT_Bounded_Queue root_q ; - // Where Aravind writes his commands - MT_Bounded_Queue command_q ; - - - - - // *********************************************************** - // Graphics objects - // *********************************************************** - - // Total applet size - int minWidth_ = 500; - int minHeight_ = 450; - - // State variables needed to be maintained - boolean connected_ = false; - int numRooms_ = 0; - - // Buttons - private CButton bConn; - private CButton bJoin; - private CButton bLeave; - private CButton bRooms; - private CButton bUsers; - - private CTextField tfCommandLine = new CTextField(80); - private CTextField tfRoomName = new CTextField(16); - private List lRooms = new List(10,false); - private Label roomLabel = new Label("Rooms:"); - private List lUsers = new List(10,false); - private Label userLabel = new Label("Users:"); - -// private RoomSpace roomspace = new RoomSpace(); - private Panel roomspace = new Panel(); - - public Dimension preferredSize() { - return minimumSize(); - } - - public Dimension minimumSize() { - return new Dimension(minWidth_, minHeight_); - } - - // ----------------------------------------------------------------- - // Basically draws up all the components (not sub-components) of the - // Applet window ... - // Pretty much straightforward barring quirks of AWT -- ArGo - void SetUpButtons(GridBagLayout gbl, GridBagConstraints gbc) { - // The Connect Button - gbc.weightx = 1.0; - gbc.weighty = 0.5; - gbc.gridx = 2; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.CENTER; - gbc.ipady = 5; - bConn = new CButton("Connect"); - bConn.setActionCommand(nexusConnector); - gbl.setConstraints(bConn, gbc); - add(bConn); - gbc.ipady = 0; - - // The remaining buttons - gbc.fill = GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.CENTER; - gbc.weightx = 1.0; - gbc.weighty = 0.5; - gbc.insets = new Insets(2,2,2,2); - gbc.ipadx = 2; - gbc.ipady = 2; - - // Join Button - gbc.gridx = 0; - gbc.gridy = 3; - bJoin = new CButton("Join"); - gbl.setConstraints(bJoin,gbc); - add(bJoin); - - // Leave Button - gbc.gridx = 1; - gbc.gridy = 3; - bLeave = new CButton("Leave"); - gbl.setConstraints(bLeave,gbc); - add(bLeave); - - // List Rooms Button - gbc.gridx = 0; - gbc.gridy = 4; - bRooms = new CButton("List Rooms"); - gbl.setConstraints(bRooms,gbc); - add(bRooms); - - // List Users Button - gbc.gridx = 1; - gbc.gridy = 4; - bUsers = new CButton("List Users"); - gbl.setConstraints(bUsers,gbc); - add(bUsers); - - } // of SetUpButtons - - void SetUpGraphics() { - - resize(preferredSize()); - - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - setFont(new Font("Helvetica", Font.PLAIN, 14)); - setLayout (gbl); - - gbc.weightx = 1.0; - gbc.weighty = 1.0; - - // For the list of rooms - // First the Room list label - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.SOUTHWEST; - gbc.fill = GridBagConstraints.NONE; - gbl.setConstraints(roomLabel,gbc); - add(roomLabel); - // Now the Room combo -- list + text field - // the actual list - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.VERTICAL; - gbc.anchor = GridBagConstraints.NORTH; - // gbc.insets = new Insets(0,2,0,2); - gbl.setConstraints(lRooms,gbc); - add(lRooms); - if (DEBUG) - lRooms.addItem("Room_1"); - // The text field - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridy = 2; - gbc.anchor = GridBagConstraints.NORTH; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.insets = new Insets(0,0,0,0); - gbl.setConstraints(tfRoomName,gbc); - add(tfRoomName); - - // Similarly for the list of users - // label - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridx = 1; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.SOUTHWEST; - gbc.fill = GridBagConstraints.NONE; - gbc.insets = new Insets(0,0,0,0); - gbl.setConstraints(userLabel,gbc); - add(userLabel); - // The list - gbc.weightx = 1; - gbc.weighty = 1; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.VERTICAL; - gbc.anchor = GridBagConstraints.NORTH; - gbl.setConstraints(lUsers,gbc); - add(lUsers); - if (DEBUG) - lUsers.addItem("USer #1"); - - // Setup all the buttons - SetUpButtons(gbl,gbc) ; - - // The command line - gbc.gridx = 0; - gbc.gridy = 5; - gbc.ipadx = 0; - gbc.ipady = 0; - gbc.insets = new Insets(0,0,0,0); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.CENTER; - gbl.setConstraints(tfCommandLine,gbc); - add(tfCommandLine); - - - // We are done -- startup with all buttons except connect disabled - OnDisconnect(); - return; - } - - public void init() { - //Get the address of the host the applet was downloaded from - host = getCodeBase().getHost(); - // Get servers portnumber from the home page - serverPort = Integer.valueOf(getParameter("serverport")); - - - // Create the nexusconnector object whose execute will be called later - // on pressing the connect button - nexusConnector = new connectionHandler(host,serverPort,this); - - if(DEBUG){ - System.out.println("Server Portnumber is " + serverPort + "\n"); - } - - // initialize the graphics - SetUpGraphics(); - } // of method init - - public synchronized void start() { - // Aravind will create the "connect" button here and register an instance - - if (DEBUG) { - System.out.println("In start() method."); - } - } - - - // Here is the stop for the applet - // Called when the user goes away from the page - public synchronized void stop() { - if (!DEBUG) { - showStatus("Stop has been called "); - } - - if (connected) { - nexusConnector.execute(null,null,null); - } - } - - - - - // ----------------------------------------------------------------------- - // Public Access functions - public Hashtable Mapper() { - return nexusJoiner.Mapper(); - } - - public String GetRoomName() { - StringTokenizer t = new StringTokenizer(tfRoomName.getText()); - if(t.hasMoreTokens()) { - return t.nextToken(); - } - else - return "" ; - } - - public void AddRoomName(String name) { - int count = lRooms.countItems(); - for (int i=0;i<count;i++) - if (lRooms.getItem(i).equalsIgnoreCase(name)) - return; - lRooms.addItem(name); - } - - public void SetRoomName(String name) { - int count = lRooms.countItems(); - for(int i=0;i<count;i++) { - if(lRooms.getItem(i).equalsIgnoreCase(name)) { - // Have to simulate a select event by doing the selection ourselves - lRooms.select(i); - tfRoomName.setText(lRooms.getSelectedItem()); - tfRoomName.selectAll(); - break ; - } - } - } - - public void sendNickToServer(String name) { - nexusJoiner.sendTestPacket("ROOT","NICK",name,nexusConnector.writer_q()); - } - - - // will run the mainthread - public void run() { - if(DEBUG) { - System.out.println("Root thread is starting -- "); - } - - root_q = new MT_Bounded_Queue(QUEUE_SIZE); - nexusJoiner.Mapper().put("ROOT",root_q); - // continously wait for something to read and then update the graphics - // objects ---- - if(DEBUG) { - nexusJoiner.sendTestPacket("ROOT","LROOMS","a b c d",root_q); - } - - for(;;) { - dataPacket rootPacket = (dataPacket)root_q.dq(); - if(DEBUG) { - System.out.println("Root got a packet --- "); - } - if(rootPacket.contentType().equalsIgnoreCase("LROOMS")) { - update_lrooms(rootPacket.content()); - } - else if(rootPacket.contentType().equalsIgnoreCase("LUSERS")) { - update_lusers(rootPacket.destination(),rootPacket.content()); - } - } - - } - - - - // This method will update the graphics of lrooms - void update_lrooms(String data) { - lRooms.disable(); - tfRoomName.disable(); - lRooms.clear(); - - StringTokenizer t = new StringTokenizer(data); - while(t.hasMoreTokens()) { - lRooms.addItem(t.nextToken()); - } - if (lRooms.countItems() != 0) { - lRooms.select(0); - tfRoomName.setText(lRooms.getItem(0)); - } - tfRoomName.enable(); - lRooms.enable(); - repaint(); - } - - void update_lusers(String name,String data) { - lUsers.disable(); - userLabel.setText("Users: "+ name); - lUsers.clear(); - StringTokenizer t = new StringTokenizer(data); - while(t.hasMoreTokens()) { - lUsers.addItem(t.nextToken()); - } - lUsers.enable(); - repaint(); - } - - // ----------------------------------------------------------------------- - // User Input handling -- ArGo - - // Function to handle Connect button being pressed - public void OnConnect(){ - // Create the event handlers -- - nexusJoiner = new joinHandler(nexusConnector.writer_q(),this); - nexusParser = new commandParser(nexusConnector.writer_q(),this); - commandLineHandler = new commandHandler(this); - // start the main thread in the applets context - mainThread = new Thread(this); - mainThread.start(); - // test - // Graphics here -- - bJoin.enable(); - bJoin.setActionCommand(nexusJoiner); - bLeave.enable(); - bLeave.setActionCommand(nexusJoiner); - bRooms.enable(); - bRooms.setActionCommand(nexusParser); - bUsers.enable(); - bUsers.setActionCommand(nexusParser); - tfCommandLine.enable(); - tfCommandLine.setActionCommand(commandLineHandler); - tfRoomName.enable(); - lRooms.enable(); - lUsers.enable(); - // Change the name to "Disconnect" and ensure that update happens - bConn.setLabel("Disconnect"); - validate(); // Don't know if this is necessary - connected = true; // Applet is now connected - } - - // Function to handle Connect button being pressed - public void OnDisconnect(){ - bJoin.disable(); - bLeave.disable(); - bRooms.disable(); - bUsers.disable(); - tfCommandLine.disable(); - tfRoomName.disable(); - lRooms.disable(); - lUsers.disable(); - // Change the name back to "Connect" and ensure update happens - bConn.setLabel("Connect"); - validate(); - // Stop the ROOT room thread - if (connected) { - mainThread.stop(); - connected = false; // Applet is disconnected - } - } - - // Basically take care of the inputs - public boolean handleEvent(Event event) { - if (event.target == lRooms) { - if (event.id == Event.LIST_SELECT) { // selected the item - tfRoomName.setText(lRooms.getSelectedItem()); - tfRoomName.selectAll(); - if (DEBUG) - System.out.println("Actually handling the select event"); - return true; - } - } - return super.handleEvent(event); - } - - public void update(Graphics g) { - paint(g); - } -} // of class NexusClientApplet - - - diff --git a/java/apps/NexusII/src/NexusIIserver.java b/java/apps/NexusII/src/NexusIIserver.java deleted file mode 100644 index e3b5a52acd5..00000000000 --- a/java/apps/NexusII/src/NexusIIserver.java +++ /dev/null @@ -1,280 +0,0 @@ -// The Nexus II server. -// Sumedh Mungee <sumedh@cs.wustl.edu> - -import java.net.*; -import java.io.*; -import java.util.*; -import ACE.OS.*; -import ACE.SOCK_SAP.*; - -public class NexusIIserver implements consts { - - // Entry point into the server - public static void main(String args[]) throws IOException { - - if(args.length != 1) { - System.out.println("Usage: java NexusIIserver <port_num>"); - return; - } - - // Create a "Hotel", which is a factory to generate Rooms - // as and when required. - RoomFactory Hotel = new RoomFactory(); - - System.out.println("NexusII server booting"); - SOCKAcceptor sacceptor = new SOCKAcceptor( (new Integer(args[0])).intValue()); - - System.out.println("NexusII is now accepting connections on port " + (new Integer(args[0])).intValue()); - - for(;;) { - - SOCKStream s = new SOCKStream(); - sacceptor.accept(s); - // Accepted connection - // construct a client handler.. - // Pass in the connected socket as an argument, - // and a reference to the Hotel, in case it needs - // to create rooms.. - // and away you go.. - new Thread(new ClientHandler(s, Hotel)).start(); - - } - } -} - - -// This thread handles the clients.. -// It uses 2 additional threads for read/write network operations -// These threads are dedicated to read/write from the -// respective read/write queues.. -class ClientHandler implements Runnable,consts { - - private SOCKStream s_; - private RoomFactory Hotel_; - private MT_Bounded_Queue rq_ = new MT_Bounded_Queue(QUEUE_SIZE); - private MT_Bounded_Queue wq_ = new MT_Bounded_Queue(QUEUE_SIZE); - private String my_name_; - private Vector roomlist_ = new Vector(); - private boolean finished_ = false; - private String init_image_; - - public ClientHandler(SOCKStream s, RoomFactory h) { - s_ = s; - Hotel_ = h; - init_image_ = new String(System.getProperty("mywebaddress") + NEXUS_LOGO); - } - - public void run() { - // Construct the reader/writer threads with the queues and the - // corresponding socket data streams as parameters. - Thread r_ = new socketReaderThread(rq_, new DataInputStream(s_.inputStream())); - Thread w_ = new socketWriterThread(wq_, new DataOutputStream(s_.outputStream())); - r_.start(); - w_.start(); - - // now start parsing the messages, and take action.. - // todo: optimize the below.. - - while(!finished_) { - dataPacket d = (dataPacket) rq_.dq(); - if(d.contentType().startsWith("INIT")) - nexus_init(d); - if(d.contentType().startsWith("JOIN")) - nexus_join(d); - if(d.contentType().startsWith("LEAVE")) - nexus_leave(d); - if(d.contentType().startsWith("QUIT")) - nexus_quit(d); - if(d.contentType().startsWith("TEXT")) - nexus_text(d); - if(d.contentType().startsWith("LUSERS")) - nexus_lusers(d); - if(d.contentType().startsWith("LROOMS")) - nexus_lrooms(d); - if(d.contentType().startsWith("NICK")) - nexus_nick(d); - if(d.contentType().startsWith("URL")) - nexus_url(d); - } - } - - // The following classes implement the server functions.. - - private void nexus_init(dataPacket packet) { - my_name_ = new String(packet.clientName()); - wq_.nq(packet); - } - - private void nexus_join(dataPacket packet) { - Room r = Hotel_.getRoom(packet.content()); - if(r.checkClient(this)) - return; - r.addClient(this); - roomlist_.addElement(r); - writeRoom(r, my_name_ + " has joined the room "); - String contenttype = new String("url"); - dataPacket d = new dataPacket(my_name_, packet.content(), contenttype, (new Integer(init_image_.length())).toString() , init_image_); - wq_.nq(d); - } - - private void nexus_text(dataPacket packet) { - Room r = Hotel_.getRoom(packet.destination()); - r.getQ().nq(packet); - } - - private void nexus_lusers(dataPacket packet) { - - Room r = Hotel_.getRoom(packet.content()); - Enumeration e = r.clientList(); - StringBuffer sb = new StringBuffer(); - while(e.hasMoreElements()) - sb.append(" " + ((ClientHandler)e.nextElement()).getName() + " "); - dataPacket d = new dataPacket(my_name_, packet.destination(), packet.contentType(), (new Integer(sb.length())).toString(), sb.toString()); - wq_.nq(d); - } - - private void nexus_lrooms(dataPacket packet) { - String s = Hotel_.listRooms(); - dataPacket d = new dataPacket(my_name_, packet.destination(), packet.contentType(), (new Integer(s.length())).toString(), s.toString()); - wq_.nq(d); - } - - private void nexus_nick(dataPacket packet) { - Enumeration e = roomlist_.elements(); - while(e.hasMoreElements()) - writeRoom((Room)e.nextElement(), my_name_ + " is now known as " + packet.content()); - - my_name_ = new String(packet.content()); - } - - private void nexus_leave(dataPacket packet) { - - Room r = Hotel_.getRoom(packet.content()); - writeRoom(r, my_name_ + " has left the room " + packet.content()); - if(r.delClient(this)) Hotel_.delRoom(r); - roomlist_.removeElement(r); - } - - private void nexus_quit(dataPacket packet) { - - Enumeration e = roomlist_.elements(); - while(e.hasMoreElements()) { - Room r = (Room)e.nextElement(); - writeRoom(r, my_name_ + " has quit " ); - r.delClient(this); - } - finished_ = true; - } - - private void nexus_url(dataPacket packet) { - try { - URL u = new URL(packet.content()); - - // first extract the filename stripped of its path. - int index = u.getFile().lastIndexOf("/"); - String infilename = u.getFile().substring(index + 1); - - // next construct the name of the temporary file - String outfilename = (System.getProperty("mywebdir") + "_" + packet.destination() + "." + infilename); - - // now the temporary URL assigned to this request - String imageURL = new String(System.getProperty("mywebaddress") + "_" + packet.destination() + "." + infilename); - - // Open temporary file for writing - FileOutputStream fout = new FileOutputStream(outfilename); - - // Now contact alien ship - InputStream i = u.openStream(); - byte[] buffer = new byte[1024]; - - // And download the image - for(;;) { - int num = i.read(buffer); - if(num < 0) - break; - fout.write(buffer, 0, num); - } - - fout.close(); - i.close(); - - // Get room for which this request was issued - Room r = Hotel_.getRoom(packet.destination()); - - // invalidate previous entry - File f = new File(r.getLastImageName()); - if(f.exists()) f.delete(); - - // add new image name - r.putNextImageName(outfilename); - writeRoom(r,"Asynchronously transferring image " + packet.content() + " from " + my_name_ ); - dataPacket d = new dataPacket(my_name_, packet.destination(), packet.contentType(), (new Integer(imageURL.length())).toString(), imageURL); - r.getQ().nq(d); // multicast this imageURL onto the room.. - - } - catch(java.net.MalformedURLException ue) { - System.out.println("warning:Invalid URL requested"); - } - catch(java.io.IOException e) { - System.out.println("warning: IOException occurred"); - } - - } - - // Sends a "system" message msg onto room r - private void writeRoom(Room r, String msg) { - StringBuffer sb = new StringBuffer(); - sb.append("==>"); - sb.append(msg); - dataPacket d = new dataPacket(my_name_, r.getName() , "TEXT" , (new Integer(sb.length())).toString(), sb.toString()); - r.getQ().nq(d); - } - - public String getName() { - return my_name_; - } - - public MT_Bounded_Queue getQ() { - return wq_; - } - -} -// ---------------------------------------------------------------------- -/** This class implements a room factory. getRoom returns an existing room, - or else creates it and returns a reference to a new room. - -**/ -class RoomFactory implements consts { - - private Vector Hotel_; - public RoomFactory() { - Hotel_ = new Vector(); - } - public synchronized Room getRoom(String name) { - Enumeration e = Hotel_.elements(); - while(e.hasMoreElements()) { - Room r = (Room) e.nextElement(); - if(r.getName().equals(name)) - return r; - } - addRoom(name); - return getRoom(name); - } - - private synchronized void addRoom(String name) { - Room r = new Room(name); - Hotel_.addElement(r); - } - public synchronized void delRoom(Room r) { - Hotel_.removeElement(r); - } - public synchronized String listRooms() { - Enumeration e = Hotel_.elements(); - StringBuffer sb = new StringBuffer(); - while(e.hasMoreElements()) - sb.append(" " + ((Room)e.nextElement()).getName() + " "); - return sb.toString(); - } -} - - diff --git a/java/apps/NexusII/src/Producer.java b/java/apps/NexusII/src/Producer.java deleted file mode 100644 index 4153f7d79df..00000000000 --- a/java/apps/NexusII/src/Producer.java +++ /dev/null @@ -1,87 +0,0 @@ -// This class encapsulates a Producer. Each new instance of this class -// creates a different thread which tries to nq into the queue -// Currently queues random values generated by the Random class -// If timeout expires, the Producer instance returns - -//package NexusII.util ; - -import java.util.Random ; - -public class Producer extends Thread -{ - -// If no time out is desired, timeout value is set to one. so the run method -// knows which nq to call - -public Producer(MT_Bounded_Queue queue) - { - this.queue_ = queue ; - this.iterations_ = new Integer(DEFAULT_ITERATIONS); - this.time_out_ = -1 ; - } - -// Include the name of the thread as a parameter -public Producer(MT_Bounded_Queue queue, String name) - { - super(name); - this.queue_ = queue ; - this.iterations_ = new Integer(DEFAULT_ITERATIONS); - this.time_out_ = -1 ; - } - -// If the number of iterations are also included -- -public Producer(MT_Bounded_Queue queue, String name, Integer iterations) - { - super(name); - this.queue_ = queue ; - iterations_ = iterations ; - this.time_out_ = -1 ; - } - -// Finally, if the timeout period is also included - -public Producer(MT_Bounded_Queue queue, String name, Integer iterations, long msec_timeout) - { - super(name); - this.queue_ = queue ; - iterations_ = iterations ; - this.time_out_ = msec_timeout ; - } - -// The hook method called by start() - -public void run() - { - // Initialize the random number generator - Random rand = new Random(); - for(int i=0;i<iterations_.intValue();i++) - { - int err = 0 ; - // Get the next random value for insertion into queue - Integer new_item = new Integer(rand.nextInt()) ; - - // Doesnt make sense to have a negative timeout -- default - if(time_out_ < 0) - queue_.nq(new_item); - else - err = queue_.nq(new_item,time_out_); - - // If timedout stop this thread - if(err == -1) - { - System.out.println(getName() + ": Timed Out \n"); - return ; - } - - System.out.println(getName() + ": enqueued " + new_item.intValue()); - } - - } - -private static final int DEFAULT_ITERATIONS = 1 ; -protected MT_Bounded_Queue queue_ ; -private Integer iterations_ ; -private long time_out_ ; -} - - diff --git a/java/apps/NexusII/src/Room.java b/java/apps/NexusII/src/Room.java deleted file mode 100644 index 4a9a294c653..00000000000 --- a/java/apps/NexusII/src/Room.java +++ /dev/null @@ -1,97 +0,0 @@ -// RoomThread and Room implement the concept of a chat "room" -// Sumedh Mungee <sumedh@cs.wustl.edu> - - -import java.util.*; -import java.io.File; - -// This class(&thread) is responsible for multicasting -// packets on its incoming "client" queues, onto one or -// more outgoing queues, which are picked up by the client. -class RoomThread implements Runnable, consts { - - private MT_Bounded_Queue rq_; - private Vector clientlist_; - - public RoomThread(MT_Bounded_Queue rq, Vector clientlist) { - rq_ = rq; - clientlist_ = clientlist; - } - - public void run() { - for(;;) { - dataPacket d = (dataPacket) rq_.dq(); // Extract packet - Enumeration e = clientlist_.elements(); // Iterate over clients - while(e.hasMoreElements()) - ((ClientHandler)e.nextElement()).getQ().nq(d); // Enqueue packet - } - } -} - - -public class Room implements consts { - - private String name_; // name of this "room" - private String last_image_ = new String("NexusII.gif"); // filename of the last image broadcast - private Thread roomthread_; - private MT_Bounded_Queue rq_ = new MT_Bounded_Queue(); - private Vector clientlist_ = new Vector(); - - // Constructors - public Room(String name) { - int i; - name_ = new String(name); - roomthread_ = new Thread(new RoomThread(rq_, clientlist_)); - roomthread_.start(); - } - - // Client management methods follow.. - - public synchronized void addClient(ClientHandler client) { - clientlist_.addElement(client); - } - // Returns true if this room has now become empty - public synchronized boolean delClient(ClientHandler client) { - clientlist_.removeElement(client); - return clientlist_.isEmpty(); - } - - public synchronized boolean checkClient(ClientHandler client) { - return clientlist_.contains(client); - } - - public synchronized Enumeration clientList() { - return clientlist_.elements(); - } - - public String getName() { - return name_; - } - - public MT_Bounded_Queue getQ() { - return rq_; - } - - public synchronized String getLastImageName() { - return last_image_; - } - - public synchronized void putNextImageName(String s) { - last_image_ = s; - } - - protected void finalize() { - roomthread_.stop(); - File f = new File(last_image_); - if(f.exists()) - f.delete(); - roomthread_ = null; - } -} - - - - - - - diff --git a/java/apps/NexusII/src/RoomFrame.java b/java/apps/NexusII/src/RoomFrame.java deleted file mode 100644 index e9da19b31d6..00000000000 --- a/java/apps/NexusII/src/RoomFrame.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:02 sumedh - Added the Nexus II source code files. - -# Revision 1.2 1996/12/07 06:25:18 rajeev -# backup -# -# Revision 1.1 1996/12/07 06:15:12 rajeev -# Initial revision -# - - -*/ -import java.awt.*; -import awtCommand.*; -import java.util.* ; - -//import NexusII.client.* ; -//import NexusII.util.* ; -//import NexusII.networking.*; - -class RoomFrame extends CFrame implements consts { - private static String rcsId = new String("$Id$"); - - // Graphics Objects - private CTextField tfInput ; - private CTextArea taOutput ; - private CButton bLeave ; - private ImageCanvas icOutput; - private Font normalFont = new Font("Helvetica", Font.PLAIN, 14); - private Font boldFont = new Font("Helvetica", Font.BOLD, 14); - private Font italicFont = new Font("Helvetica", Font.ITALIC, 14); - private static final int LINE_LENGTH = 70; - - // Other required objects - private MT_Bounded_Queue write_q_ ; - private NexusClientApplet applet_ ; - private String myName_ ; - - public RoomFrame(MT_Bounded_Queue write_q, - NexusClientApplet applet, - String name) { - super(name); - write_q_ = write_q ; - applet_ = applet ; - myName_ = name ; - SetUpGraphics(); - this.pack(); - this.show(); - } - - void SetUpGraphics() { - // Initialize the graphics objects - // The input text line - tfInput = new CTextField(LINE_LENGTH); - textHandler handlerT = new textHandler(write_q_,applet_,myName_); - tfInput.setActionCommand(handlerT); - // The leave button - bLeave = new CButton(LEAVE_STR); - bLeave.setActionCommand(applet_.nexusJoiner); - - icOutput = new ImageCanvas(myName_); - taOutput = new CTextArea(10,LINE_LENGTH); - - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - setFont(normalFont); - setLayout (gbl); - - gbc.insets = new Insets(5,5,5,5); - gbc.ipadx = 5; - gbc.ipady = 5; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - - // First the Image so that sizes are fixed - gbc.gridx = 1; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.CENTER; - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(icOutput, gbc); - add(icOutput); - - // The Text Output Area - gbc.gridx = 0; - gbc.gridy = 0; - gbc.weighty = 0.0; - gbc.anchor = GridBagConstraints.SOUTH; - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(taOutput,gbc); - taOutput.setEditable(false); - add(taOutput); - - // The Text Input Field - gbc.gridx = 0; - gbc.gridy = 1; - gbc.weighty = 0.0; - gbc.anchor = GridBagConstraints.NORTH; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(tfInput,gbc); - add(tfInput); - - // The Leave Button - gbc.gridx = 1; - gbc.gridy = 1; - gbc.anchor = GridBagConstraints.NORTH; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(bLeave,gbc); - add(bLeave); - - resize(800,280); - setResizable(true); // Allow the user to resize - validate(); - } - - public boolean handleEvent(Event event) { - if (event.id == Event.WINDOW_DESTROY) - dispose(); - return super.handleEvent(event); - } - - // This function will be called by the RoomHandler when it receives - // anything for this room and will add the data - public void addText(String tobeadded) { - if (false) { - String speaker = null; - String msg = null; - int pos = tobeadded.indexOf(':'); - if (pos >= 0) - speaker = tobeadded.substring(0,pos+1); - else - speaker = new String(""); - msg = tobeadded.substring(pos+1); - Font oldf = taOutput.getFont(); - taOutput.setFont(boldFont); - taOutput.appendText(speaker); - taOutput.setFont(italicFont); - taOutput.appendText(msg+"\n"); - taOutput.setFont(oldf); - } - else { - taOutput.appendText(tobeadded+"\n"); - } - return; - } - - // This function will also be called by the RoomHandler whenit receives - // Image data for this room. - public void updateImage(Image im) { - if(DEBUG) { - System.out.println("Room : I got an image"); - } - icOutput.setImage(im); - } - - -} - - - -/** - * The ImageCanvas Class -- for the image in the class - */ -class ImageCanvas extends Canvas implements consts { - - Image image_ = null; - int defWidth_ = 128; - int defHeight_ = 128; - int margin = 5; - - String name_ = new String("Nexus Room"); - Font nameFont = new Font("Helvetica",0,14); - - public ImageCanvas(String s) - { - name_ = s; - } - - public Dimension preferredSize() { - return minimumSize(); - } - public Dimension minimumSize() { - return new Dimension(defWidth_, defHeight_); - } - - public void setImage(Image newIm) { - image_ = newIm; - repaint(); - } - public Image getImage() { - return image_; - } - - public void name(String n) { - name_ = n; - } - public String name() { - return name_; - } - - public void paint(Graphics g) { - Dimension d = size(); - int width = d.width; - int height = d.height; - - if (DEBUG) - System.out.println("ImageCanvas:: width = "+width+ " height="+height); - - g.setColor(Color.black); - g.fillRect(0,0,width-1,height-1); - g.setColor(Color.white); - g.fillRect(margin,margin,width-2*margin,height-2*margin); - // Create image if reqd - if (image_ == null) - image_ = createImage(width-2*margin,height-2*margin); - - g.drawImage(image_, margin, margin, - width-2*margin, height-2*margin, Color.white, this); - g.setColor(Color.blue); - g.setFont(nameFont); - FontMetrics fm = g.getFontMetrics(); - g.drawString(name_,(width - fm.stringWidth(name_))/2, - (int)(height*0.9 - fm.getMaxDescent())); - validate(); - return; - } - - public void update(Graphics g) { - paint(g); - } - -} // End of the Image Canvas Class - - - -// this is the event handler for the textfield -- whenever anything is typed -class textHandler implements Command,consts,Runnable { - private MT_Bounded_Queue write_q_ ; - private NexusClientApplet applet_ ; - private String name_ ; - Object what_ ; - - public textHandler(MT_Bounded_Queue write_q, - NexusClientApplet applet, - String name) { - write_q_ = write_q ; - applet_ = applet ; - name_ = name ; - } - - public void execute(Object target, Event evt, Object what) { - // get the string and send it across in a different thread - what_ = what ; - // clear the field in the gui - ((TextField)target).setText(""); - // send it off - new Thread(this).start(); - } - - // send off the string in a different thread - public void run() { - String data = (String)what_; - // check if data begins with / and is followed by url - if(!data.startsWith("/url")) { - - String user = NexusClientApplet.myName ; - String command = user + ":" + data ; - String len = Integer.toString(command.length()); - dataPacket packet = new dataPacket(NexusClientApplet.myName,name_, - "TEXT",len,command); - write_q_.nq(packet); - } - else { - // it is /url - StringTokenizer t = new StringTokenizer(data); - // take out the /url from here - String ur = t.nextToken(); - // data now - String command = t.nextToken(); - String len = Integer.toString(command.length()); - dataPacket packet = new dataPacket(NexusClientApplet.myName,name_, - "URL",len,command); - write_q_.nq(packet); - } - } -} // end of class - - - diff --git a/java/apps/NexusII/src/RoomSpace.java b/java/apps/NexusII/src/RoomSpace.java deleted file mode 100644 index 9afb78ddff1..00000000000 --- a/java/apps/NexusII/src/RoomSpace.java +++ /dev/null @@ -1,110 +0,0 @@ -import java.awt.*; - -class RoomFrame extends Frame // implements Runnable -{ - - // Graphics Objects - private Panel panel = new Panel(); - private TextField tfInput = new TextField(80); - private TextArea taOutput = new TextArea(80,10); - Button bLeave = new Button("Leave"); - ImageCanvas icOutput = new ImageCanvas(); - - void InitGraphics() - { - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - setFont(new Font("Helvetica", Font.PLAIN, 14)); - panel.setLayout (gbl); - - gbc.weightx = 1.0; - gbc.weighty = 1.0; - - // First the Image so that sizes are fixed - gbc.gridx = 1; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.CENTER; - gbc.fill = GridBagConstraints.NONE; - gbl.setConstraints(icOutput, gbc); - panel.add(icOutput); - - // The Text Output Area - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.WEST; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(taOutput,gbc); - taOutput.setEditable(false); - panel.add(taOutput); - - // The Text Input Field - gbc.gridx = 0; - gbc.gridy = 1; - gbc.anchor = GridBagConstraints.WEST; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(tfInput,gbc); - panel.add(tfInput); - - // The Leave Button - gbc.gridx = 1; - gbc.gridy = 1; - gbc.anchor = GridBagConstraints.WEST; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbl.setConstraints(bLeave,gbc); - panel.add(bLeave); - } - - - public RoomFrame() - { - this("Anonymous"); - } - - public RoomFrame(String s) - { - InitGraphics(); - super(s); - this.pack(); - this.show(); - } - - public boolean handleEvent(Event event) - { - if (event.id == Event.WINDOW_DESTROY) - dispose(); - return super.handleEvent(event); - } - -} - -class ImageCanvas extends Canvas { - - Image image_; - int imgWidth_ = 128; - int imgHeight_ = 128; - - public Dimension preferredSize() { - return minimumSize(); - } - - public Dimension minimumSize() { - return new Dimension(imgWidth_, imgHeight_); - } - - public void image(Image newIm) { - image_ = newIm; - } - - public Image image() { - return image_; - } - - public void paint(Graphics g) { - g.drawImage(image_,0,0,this); - } - - public void update() { - paint(); - } - -} // End of the Image Canvas Class diff --git a/java/apps/NexusII/src/Timed_Wait.java b/java/apps/NexusII/src/Timed_Wait.java deleted file mode 100644 index 792db39ceb9..00000000000 --- a/java/apps/NexusII/src/Timed_Wait.java +++ /dev/null @@ -1,86 +0,0 @@ -// package NexusII.util ; - - -// Subclass the Exception class to get TimeoutException - -class TimeoutException extends Exception -{ - public TimeoutException() - { - super(); - } - - public TimeoutException(String s) - { - super(s); - } - -} - -// Timed_wait class. This can used by enq and deq to do timed_waits -public abstract class Timed_Wait -{ - // By default the object is itself -public Timed_Wait () - { - object_ = this; - } - // If the calling class specifies objects, delegate to it. -public Timed_Wait (Object obj) - { - object_ = obj; - } - - // This is the object we delegate to if a - // subclass gives us a particular object, - // otherwise, we ``delegate'' to ourself - // (i.e., to this). -protected Object object_; - - // This hook method must be overridden - // by a subclass to provide the condition. - -public abstract boolean condition (); - - // This will borrow the monitor lock from the calling class - -public final void timed_wait(long msec_timeout) -throws InterruptedException, TimeoutException - { - // wait if the condition is false - if (!condition()) - { - long start = System.currentTimeMillis() ; - long wait_time = msec_timeout ; - - for(;;) - { - // anyway have to wait atleast till waittime - object_.wait(wait_time); - - // on coming out check for the condition again - if(!condition()) - { - long now = System.currentTimeMillis() ; - long time_so_far = now - start ; - - // if timed out - if(time_so_far >= msec_timeout) - throw new TimeoutException() ; - else - // retry !! we have some time left - wait_time = msec_timeout - time_so_far ; - } - else // the condition is true here - break ; - } - } - } - - // Notify all threads waiting on the object_. -public final void broadcast () - { - object_.notifyAll (); - } -} - diff --git a/java/apps/NexusII/src/Timer.java b/java/apps/NexusII/src/Timer.java deleted file mode 100644 index df781274913..00000000000 --- a/java/apps/NexusII/src/Timer.java +++ /dev/null @@ -1,31 +0,0 @@ -// This class encapsulates a Timer mechanism -// Can be used for Profiling of parts of code and gathering statistics - -package NexusII ; - -public class Timer { - -public Timer() -{ - start_ = 0 ; -} - -public void start() - -{ - start_ = System.currentTimeMillis(); -} - -public long elapsed_time() -{ - return System.currentTimeMillis() - start_ ; -} - -public void stop() -{ - start_ = 0 ; -} - -private long start_ = 0 ; - -} diff --git a/java/apps/NexusII/src/commandHandler.java b/java/apps/NexusII/src/commandHandler.java deleted file mode 100644 index 4cf80d04235..00000000000 --- a/java/apps/NexusII/src/commandHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -// To handle the events generated by command-line. The user will be saying -// /nick <nick-name> - -import java.awt.* ; -import java.util.* ; - -//import NexusII.client.* ; - -import awtCommand.* ; - - -public class commandHandler implements Command,consts { - NexusClientApplet applet_ ; - // will handle the /nick command for now -- urgent - public commandHandler(NexusClientApplet applet ) { - applet_ = applet ; - } - - public void execute(Object target,Event evt,Object what) { - // Right now assume that it is just a nick command - if(DEBUG) { - System.out.println("Nick typed in ---- "); - } - StringTokenizer t = new StringTokenizer((String)what) ; - // string for holding /nick and <nickname> - String command = null ; - if(t.hasMoreTokens()) { - command = t.nextToken(); - } - - if(command.equalsIgnoreCase("/nick")) { - if(t.hasMoreTokens()) { - // have to send a nick packet to server - applet_.myName = new String(t.nextToken()); - applet_.sendNickToServer(applet_.myName); - - } - } - // clear the field in the gui - ((TextField)target).setText(""); - - } -} -// of class diff --git a/java/apps/NexusII/src/commandParser.java b/java/apps/NexusII/src/commandParser.java deleted file mode 100644 index 64e6da66122..00000000000 --- a/java/apps/NexusII/src/commandParser.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:06 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:05:08 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// why not use java utilities !! - -import java.util.* ; -import java.lang.* ; -import java.awt.* ; - - - -//import NexusII.client.* ; -//import NexusII.util.* ; -//import NexusII.networking.* ; - - - -import awtCommand.* ; - -// This class takes a command parses it and packetizes it and puts it in the -// global send queue. It works in its own thread of control and after nqing -// its run() method falls off. It does its work and dies -// Will act as an eventHandler for TextField most probably - -public class commandParser implements Command,consts,Runnable { - - String command ; - MT_Bounded_Queue q_ ; - NexusClientApplet applet_ ; - // constructor - - public commandParser(MT_Bounded_Queue write_q,NexusClientApplet applet) { - // create a reference to the write_q - q_ = write_q ; - // note the applet name - applet_ = applet ; - - } - - - public void execute(Object target, Event evt, Object what) { - // Get the text which was entered there -- - command = new String((String) what) ; - // run in a separate thread - Thread main = new Thread(this); - main.start(); - } - - // The parser etc. run here - public synchronized void run() { - String actual_command = new String(); - String data = new String(); - String data_len = new String(); - if(DEBUG) { - System.out.println("commandParser thread running --- \n"); - } - - // Do the parsing first - if(command.equalsIgnoreCase(LUSERS_STR)) { - actual_command = new String("LUSERS") ; - data = applet_.GetRoomName() ; - data_len = new String(String.valueOf(data.length())); - if(data.length() == 0) - return ; - } - - else if(command.equalsIgnoreCase(LROOMS_STR)) { - actual_command = new String("LROOMS") ; - data = new String("") ; - data_len = new String("0") ; - } - - String room = new String("ROOT"); - - if(DEBUG) { - System.out.println("The room is " + room + "\n"); - } - - /* - StringBuffer databuffer = new StringBuffer(); - - // Get the data - while(t.hasMoreTokens()) { - databuffer.append(t.nextToken()); - } - String data = new String(databuffer); - if(DEBUG) { - System.out.println("The data is " + data + "\n"); - } - - // data length - String data_len = String.valueOf(data.length()); - // Now make a packet - */ - - dataPacket pack = new dataPacket(NexusClientApplet.myName,room,actual_command,data_len,data); - // enqueue it now - q_.nq(pack); - - } // my job is over - -} -// of class - diff --git a/java/apps/NexusII/src/connectionHandler.java b/java/apps/NexusII/src/connectionHandler.java deleted file mode 100644 index 5e9d3823a68..00000000000 --- a/java/apps/NexusII/src/connectionHandler.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:07 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:05:30 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// This class will handle the event generated when user presses "connect/dis -// connect" button. It will maintain all the state associated with a -// connection ; -// In particular, it will create reader,writer and demux threads and stop -// them when user pressed disconnect. It also sends the init and quit -// packet to the server -// -- Rajeev Bector 11/26/96 - -// package NexusII.networking ; - -import awtCommand.* ; - -import java.net.* ; -import java.awt.* ; -import java.io.* ; -import java.util.* ; -import ACE.OS.*; -import ACE.SOCK_SAP.*; - -public class connectionHandler implements Command,consts,Runnable { - - // The socket for reading and writing - // private Socket nexusSocket; - private SOCKConnector nexusConnector_ = new SOCKConnector(); - private SOCKStream nexusStream_ = new SOCKStream(); - - // Threads which will do reading and writing from Socket - private Thread readerThread ; - private Thread writerThread ; - - // Threads which demuxes the data from Write Queue - private Thread demuxThread; - - // The socket - // private Socket nexusSocket_ ; - - // Data Streams which flow the data out - private DataInputStream is_ ; - private DataOutputStream os_ ; - - // links to the outside world - private MT_Bounded_Queue read_q_ ; - private MT_Bounded_Queue write_q_ ; - - Integer port_ ; - String host_ ; - - NexusClientApplet applet_ ; - // Constructor - public connectionHandler(String host,Integer port,NexusClientApplet applet) { - host_ = host ; - port_ = port ; - applet_ = applet ; - } // of constructor - - // This will be called when the "connect/disconnet" button is pressed - - public void execute(Object target, Event evt, Object what) { - // run in a separate thread - new Thread(this).start(); - } - - public synchronized void run() { - - // If not connected -- then connect - if(!applet_.connected) { - - // Initialize the queues now - read_q_ = new MT_Bounded_Queue(QUEUE_SIZE); - write_q_ = new MT_Bounded_Queue(QUEUE_SIZE); - - // Try to connect to the server now - // nexusSocket_ = new Socket(host_,port_.intValue()); - try { - nexusConnector_.connect(nexusStream_, host_, port_.intValue()); - } - catch(SocketException s) { } - catch(IOException i) { } - // Attach Streams to read and write end os socket - os_ = new DataOutputStream(nexusStream_.outputStream()); - is_ = new DataInputStream(nexusStream_.inputStream()); - - // do something now - - // create and start the socket reader first - readerThread = new socketReaderThread(read_q_,is_); - readerThread.start(); - - // now create the writer also -- subclass of consumer - writerThread = new socketWriterThread(write_q_,os_); - writerThread.start(); - // Have to send the init packet to the server - sayHelloToServer(); - - - // Do all the graphics needed and also init the join handlers etc. - applet_.OnConnect(); - - // make sure that when demux is created -- joinHandler is there ... !! - - // Create the demux here -- he'll spawn off the rooms - demuxThread = new nexusDemuxThread(read_q_,applet_.Mapper()); - demuxThread.start(); - - } // of if !connected - - // if connected already then I have to disconnect --- have to - // write code for this - else { - - // first leave all the rooms - for(Enumeration e = applet_.Mapper().keys(); e.hasMoreElements();) { - String name = (String) e.nextElement() ; - applet_.SetRoomName(name); - applet_.nexusJoiner.execute(null,null,LEAVE_STR); - } - // send a quit packet to the server - sayByeToServer(); - - // Have to send a leave for all the rooms and leave all the rooms - - // stop the running threads - readerThread.stop(); - demuxThread.stop(); - - // Again meddle with graphics - applet_.OnDisconnect(); - return ; - } - } // of run - - // This method returns the underlying socket descriptor - public Socket handle() { - return nexusStream_.socket(); - } - - public DataInputStream getinStream() { - return is_ ; - } - - public DataOutputStream getoutStream() { - return os_ ; - } - - public MT_Bounded_Queue reader_q() { - return read_q_ ; - } - - - public MT_Bounded_Queue writer_q() { - if(write_q_ == null) - System.out.println("Sending a null write_q"); - return write_q_ ; - } - - // This method will compose a hello packet and send it off -- cannot run - // this in a separate thread. Has to send this first surely to our TCP - // Connection - - public void sayHelloToServer() { - // hello doesnt have any body - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String roomID = new String("ROOT"); - String contentType = new String("INIT"); - String contentLength = new String("0"); - - // Make a proper packet out of it - dataPacket initPacket = new dataPacket(clientID,roomID,contentType,contentLength); - - // enqueue that packet for socketWriter to read - write_q_.nq(initPacket); - - } - - // This method send a Quit command to the server -- to say that it is - // pushing off - public void sayByeToServer() { - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String roomID = new String("null"); - String contentType = new String("QUIT"); - String contentLength = new String("0"); - - // Make a proper packet out of it - dataPacket quitPacket = new dataPacket(clientID,roomID,contentType,contentLength); - - // enqueue that packet for socketWriter to read - write_q_.nq(quitPacket); - } // of sayByeToServer - -} // of class - - - - - - - - - - - - - - - - - - - - - diff --git a/java/apps/NexusII/src/consts.java b/java/apps/NexusII/src/consts.java deleted file mode 100644 index 304ec41a41e..00000000000 --- a/java/apps/NexusII/src/consts.java +++ /dev/null @@ -1,40 +0,0 @@ -// package NexusII.client ; - -// An interface for all the public constants shared by clientApplet -// All classes that need to access constants will implement this - -public interface consts { - // Length of each field in the header - public static final int FIELD_LENGTH = 32 ; - - // Total length of header - public static final int PACKET_HEADER_LENGTH = 128; - - // Offset where we can find the data length - public static final int DATA_LEN_OFFSET = 96; - - // Size of Queues where reader and writer work - public static final int QUEUE_SIZE = 20 ; - - // Separator used by tokens in the packet - public static final String SEPARATOR = " " ; - - // End of message - public static final String END_OF_DATA = "\n" ; - - // Useful for debugging -- set to false for release version (demo) -- Aravind - public static final boolean DEBUG = false; - - // Size of hash tables - public static final int HASH_SIZE = 16 ; - - public static final String JOIN_STR = "Join" ; - public static final String LEAVE_STR = "Leave" ; - public static final String LUSERS_STR = "List Users" ; - public static final String LROOMS_STR = "List Rooms" ; - - public static final int SERVER_PORT = 42429 ; - public static final String NEXUS_LOGO = "Nexus_Logo.gif"; -} - - diff --git a/java/apps/NexusII/src/dataPacket.java b/java/apps/NexusII/src/dataPacket.java deleted file mode 100644 index 1bd2dfeb6ab..00000000000 --- a/java/apps/NexusII/src/dataPacket.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:08 sumedh - Added the Nexus II source code files. - -# Revision 1.2 1996/12/07 06:27:38 rajeev -# yaah paranoid backup ... -# -# Revision 1.1 1996/12/06 18:23:45 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:07:53 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// This class encapsulates a dataPacket -// Will encapsulate the byteStream as a characterStream into a single thing -// no packets for now -// package NexusII.networking ; - -//import NexusII.client.* ; - -public class dataPacket implements consts, Cloneable{ - - private String clientName ; - private String roomName ; - private String contentType ; - private String contentLength ; - private String content ; - - // constructor -- will create the data packet - public dataPacket(byte[] header, byte[] body) { - int len = FIELD_LENGTH ; - clientName = new String(header,0,0,len); - roomName = new String(header,0,1*len,len); - contentType = new String(header,0,2*len,len); - contentLength = new String(header,0,3*len,len); - content = new String(body,0); - if(DEBUG) - System.out.println("datapacket: Constructed packet with header " + header + " and body " + body); - } - - // another constructor for length 0 packets - public dataPacket(String client, String room, String type,String len) - { - clientName = new String(client); - roomName = new String(room); - contentType = new String(type); - contentLength = new String(len); - content = new String(); - } - - // another one for some data also - public dataPacket(String client, String room, String type,String len,String data) - { - this(client,room,type,len); - content = new String(data); - } - - // return the data in bytized header and body - public void bytize(byte[] header, byte[] body) - { - // clear the header and body -- fill them with whitespace - String white_space = new String(" "); - - if(DEBUG) { - System.out.println("dataPacket: length is " + new Integer(contentLength.trim()).intValue() + "\n"); - } - - int len = FIELD_LENGTH ; - // copy the header - clientName.getBytes(0,clientName.length(),header,0); - roomName.getBytes(0,roomName.length(),header,len*1); - contentType.getBytes(0,contentType.length(),header,len*2); - contentLength.getBytes(0,contentLength.length(),header,len*3); - - int body_len = (new Integer(contentLength.trim())).intValue(); - // copy the body also - content.getBytes(0,body_len,body,0); - } - - public int contentLength() { - return new Integer(contentLength.trim()).intValue(); - } - - // Returns the destination for the current packet - public String destination(){ - return roomName.trim() ; - } - - public String contentType() { - return contentType.trim() ; - } - - - public String content() { - return content.trim() ; - } - - public String clientName() { - return clientName.trim() ; - } - -} -// of class datapacket - - - - - - - - diff --git a/java/apps/NexusII/src/joinHandler.java b/java/apps/NexusII/src/joinHandler.java deleted file mode 100644 index 3ff071c26ed..00000000000 --- a/java/apps/NexusII/src/joinHandler.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:09 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:06:22 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ - -// This class will handle the event generated when user presses "join/leave" -// button. It will maintain all the state associated with all the rooms -// It'll also create and maintain the rooms -// -- Rajeev Bector 11/26/96 - -// package NexusII.networking ; - -// This is a SINGLETON - - -import java.net.* ; -import java.util.* ; -import java.awt.* ; -import java.io.* ; - - -//import NexusII.client.* ; -//import NexusII.util.* ; -//import NexusII.networking.* ; - -import awtCommand.* ; - -public class joinHandler implements Command,consts { - MT_Bounded_Queue write_q_ ; - Hashtable name_to_q_ ; - Hashtable name_to_handler_ ; - NexusClientApplet applet_ ; - - // This will be called when the "join/leave" button is pressed - public joinHandler(MT_Bounded_Queue writer_q,NexusClientApplet applet) { - write_q_ = writer_q ; - applet_ = applet ; - // init. the Hashtables - name_to_q_ = new Hashtable(HASH_SIZE); - name_to_handler_ = new Hashtable(HASH_SIZE); - - } - - public Hashtable Mapper() { - return name_to_q_ ; - } - - public void execute(Object target, Event evt, Object what) { - - String roomName = applet_.GetRoomName() ; - if(roomName.length()==0) { - return ; - } - - // if it is the join button - if(((String)what).equalsIgnoreCase(JOIN_STR)) { - //if already joined -- return - if(name_to_q_.get(roomName) != null) - return ; - - // room doesnt exist - // Just in case the room name isn't listed - applet_.AddRoomName(roomName); - // create a new queue for the room to use - - MT_Bounded_Queue q_ = new MT_Bounded_Queue(QUEUE_SIZE); - if(DEBUG) { - System.out.println("joinHandler: inserted the queue in hash "); - } - name_to_q_.put(roomName,q_); - roomHandler handler = new roomHandler(roomName,q_,write_q_,applet_); - name_to_handler_.put(roomName,handler); - - // send a request to the server - sayJoinToServer(roomName); - // sendTestPacket(roomName,"URL","http://cumbia.cs.wustl.edu:4242/~sumedh/NexusII/NexusII.gif",q_); - } // of join - - else { - // its a "leave packet" - if(name_to_q_.get(roomName) == null) - return ; - // remove the entry from the queue - name_to_q_.remove(roomName); - - roomHandler handle = (roomHandler) name_to_handler_.get(roomName); - if(DEBUG) - System.out.println("joinHandler:Stopiing the room thread" + roomName); - handle.mystop(); - // handle = null ; - - // remove the entry from the queue - name_to_handler_.remove(roomName); - sayLeaveToServer(roomName); - } // of else - } // of execute - - private void sayJoinToServer(String roomName) { - //if (DEBUG) - // System.out.println("In the say J to server..."); - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String roomID = new String("ROOT"); - String contentType = new String("JOIN"); - String contentLength = String.valueOf(roomName.length()); - String content = new String(roomName); - // Make a proper packet out of it - dataPacket joinPacket = new dataPacket(clientID,roomID,contentType,contentLength,content); - - // enqueue that packet for socketWriter to read - write_q_.nq(joinPacket); - } - - private void sayLeaveToServer(String roomName) { - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String roomID = new String("ROOT"); - String contentType = new String("LEAVE"); - String contentLength = new String(Integer.toString(roomName.length())); - String content = new String(roomName); - - // Make a proper packet out of it - dataPacket leavePacket = new dataPacket(clientID,roomID,contentType,contentLength,content); - - // enqueue that packet for socketWriter to read - write_q_.nq(leavePacket); - } - - - public void sendTestPacket(String roomName,String type,String content,MT_Bounded_Queue readq) { - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH] ; - String clientID = new String(NexusClientApplet.myName); - String contentLength = new String(Integer.toString(content.length())); - - - // Make a proper packet out of it - dataPacket testPacket = new dataPacket(clientID,roomName,type,contentLength,content); - - // enqueue that packet for socketWriter to read - readq.nq(testPacket); - } - - -} - -// of class - - - - - - - - - - - - - - - - diff --git a/java/apps/NexusII/src/makefile b/java/apps/NexusII/src/makefile deleted file mode 100644 index c3cff521511..00000000000 --- a/java/apps/NexusII/src/makefile +++ /dev/null @@ -1,15 +0,0 @@ -all: client server - -client: ../classes/NexusClientApplet.class - -../classes/NexusClientApplet.class: - javac -d ../classes -depend -g NexusClientApplet.java - -server: ../classes/NexusIIserver.class - -../classes/NexusIIserver.class: - javac -d ../classes -depend -g NexusIIserver.java - -clean: - rm -f ../classes/*.class *~ - diff --git a/java/apps/NexusII/src/nexusDemuxThread.java b/java/apps/NexusII/src/nexusDemuxThread.java deleted file mode 100644 index 96d0fdd06e1..00000000000 --- a/java/apps/NexusII/src/nexusDemuxThread.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:10 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.2 1996/12/05 05:39:47 sumedh -# ok -# -# Revision 1.1 1996/12/02 06:08:20 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ - -// Will take the packets from the input queue -// Parse the packet -// Call the room handler thread which Aravind will provide - -// Mapper object is the one which returns the room_q reference if you pass -// it the room number. Aravind has to implement this object called roomMapper -// which has an instance called mapper in the Applet context. This will be -// referred by nexusDemuxThread whenever it has anything to put in the room_q - -// package NexusII.networking ; - -//import NexusII.util.* ; -//import NexusII.client.* ; - -import java.util.* ; - -public class nexusDemuxThread extends Thread implements consts { - MT_Bounded_Queue q_ ; - dataPacket packet ; - Hashtable mapper_ ; - - // constructor - public nexusDemuxThread(MT_Bounded_Queue read_q,Hashtable mapper) { - q_ = read_q ; - mapper_ = mapper ; - } - - public void run() { - // run till infinity - for(;;) { - if(DEBUG) { - System.out.println("Demux running ---- "); - } - // take out packets from the queue - // parse to find out which room they belong to - packet = ((dataPacket)q_.dq()); - if(DEBUG) { - System.out.println("Demux got something ---- "); - } - - String roomName = packet.destination().trim(); - if(DEBUG) { - System.out.println("demux: destination is : " + roomName); - } - if(DEBUG) { - System.out.println("Hashtable size is " + new Integer(mapper_.size())); - } - // Get a reference to which queue to put it in - MT_Bounded_Queue room_q = (MT_Bounded_Queue)mapper_.get(roomName); - - // nq the packet on the room q - if(room_q != null) { - room_q.nq(packet); - System.out.println("deMux: I have enqueued it successfully"); - } - else - { - System.out.println("demux: room_q was null: i couldnt do much"); - } - } - } - // of run -} -// of class - - - - - -// 11/24/96 -- Rajeev Bector diff --git a/java/apps/NexusII/src/roomHandler.java b/java/apps/NexusII/src/roomHandler.java deleted file mode 100644 index bd125631b74..00000000000 --- a/java/apps/NexusII/src/roomHandler.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:11 sumedh - Added the Nexus II source code files. - -# Revision 1.4 1996/12/07 06:22:49 rajeev -# taking a backup ! -# -# Revision 1.3 1996/12/06 06:20:07 rajeev -# Changes to include leave handler -# -# Revision 1.2 1996/12/06 04:49:44 rajeev -# working now hopefully ! -# -# Revision 1.1 1996/12/06 03:44:32 rajeev -# Initial revision -# - -*/ - -// per room -import java.awt.* ; -import awtCommand.* ; -import java.io.* ; -import java.net.* ; -//import NexusII.client.* ; -//import NexusII.util.* ; -//import NexusII.networking.*; - -public class roomHandler implements Runnable,consts{ - - String roomName_ ; - MT_Bounded_Queue read_q_ ; - MT_Bounded_Queue write_q_ ; - RoomFrame rf_; - Thread mainThread ; - NexusClientApplet applet_ ; - - // I dont know what to do currently - public roomHandler(String roomName, MT_Bounded_Queue reader_q,MT_Bounded_Queue writer_q,NexusClientApplet applet) { - roomName_ = roomName ; - read_q_ = reader_q ; - write_q_ = writer_q ; - applet_ = applet ; - rf_ = new RoomFrame(write_q_,applet_,roomName_); - // whenever this frame gets the mouse focus, handler will be called - FrameHandler fh_ = new FrameHandler(applet_); - rf_.setGotFocusCommand(fh_); - mainThread = new Thread(this); - mainThread.start(); - } - - - public void mystop() { - // dispose the graphics part here - if(DEBUG) - System.out.println("Roomhandlers stop called \n"); - rf_.hide(); - rf_.dispose(); - // no longer need the roomframe - rf_ = null ; - mainThread.stop(); - } - - public void run() { - if(DEBUG) { - System.out.println("Room receiver running ---- "); - } - while(Thread.currentThread() == mainThread) { - // get the data packet - dataPacket packet = (dataPacket)(read_q_.dq()) ; - if(DEBUG) - System.out.println("Room - I got something\n"); - - // if the packet is of text type -- display it - if(packet.contentType().trim().equalsIgnoreCase("TEXT")) { - rf_.addText(packet.content()); - } - // if the packet is a url address -- pull the image across - // this url has to be an image as of now - if(packet.contentType().equalsIgnoreCase("URL")) { - Image im = null ; - try { - im = applet_.getImage(new URL(packet.content())); - } catch (MalformedURLException i) { - // nothing as of now - } - // display the image - rf_.updateImage(im); - - } - - if (DEBUG) - System.out.println("roomhandler" + roomName_ + " got data"); - } - } - - public String toString() { - return roomName_ ; - } - -} // of class roomHandler - -// is executed when the room frame gets mouse focus - -class FrameHandler implements Command { - NexusClientApplet applet_ ; - public FrameHandler(NexusClientApplet applet) { - applet_ = applet ; - } - - public void execute(Object target, Event evt, Object what) { - if(target instanceof Frame) { - applet_.SetRoomName(((RoomFrame)target).getTitle()); - } - } -} - diff --git a/java/apps/NexusII/src/socketReaderThread.java b/java/apps/NexusII/src/socketReaderThread.java deleted file mode 100644 index 35679c504b4..00000000000 --- a/java/apps/NexusII/src/socketReaderThread.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:11 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.3 1996/12/03 01:35:37 rajeev -# fixed a big bug with respect to trim() -# -# Revision 1.2 1996/12/03 01:01:27 rajeev -# // fixed the bug at line 76 -# -# Revision 1.1 1996/12/02 06:08:56 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// The socketReaderThread is like a Producer who reads from the socket and -// nqs it onto the queue. Thats it ... Big Deal. huh ! - -// This threads task is -// 1. Take things from SocketBuffer. -// 2. Ensure that Full Packets are read -// 3. Put the packet onto the queue - -//package NexusII.networking ; - -// get hold of java classes -//import NexusII.client.* ; -//import NexusII.util.* ; - -import java.io.* ; - - -public class socketReaderThread extends Producer implements Runnable,consts -{ - DataInputStream is_ ; - - // new constructor - // Pass the queue and socketid to the constructor - - public socketReaderThread(MT_Bounded_Queue q, DataInputStream is) { - // call the super constructor - super(q); - is_ = is ; - } - - // This will just override the run method and thats it - // I want to have my own run ! - - public void run() { - // run indefinitely -- i am a daemon anyway - if(DEBUG) { - System.out.println("--- This is socketReaderThread --- \n"); - } - - for(;;) { - - // read header bytes from stream - int field_len = FIELD_LENGTH ; - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH]; - try { - is_.readFully(packetHeader,0,PACKET_HEADER_LENGTH); - } - catch (IOException e) { - // do something here - System.out.println("socketReader: I/O exception in read: I am quitting"); - // what to do here -- right now quit - return ; - } - if(DEBUG){ - System.out.println("socketReader read:" + new String(packetHeader,0)); - } - - // take out the length field from this - String length = new String(packetHeader,0,DATA_LEN_OFFSET,field_len); - - // Read this much more from the socket - if(DEBUG) { - System.out.println("The length of packet is " + length); - } - - Integer Test = new Integer(length.trim()); - int len = Test.intValue(); - if(DEBUG) { - System.out.println("srt: attempting to read " + Test + " bytes "); - } - - byte[] packetBody = new byte[len] ; - try { - if(len != 0) - is_.readFully(packetBody,0,len); - } - catch (IOException e) { - // do something here - System.out.println("socketReader: I/O exception in read: I am quitting"); - // what to do here -- right now quit - return ; - } - - // The header and the body are there now -- so make a packet - dataPacket packet = new dataPacket(packetHeader,packetBody); - if(DEBUG) - System.out.println("srt: Now nq'ing item body " + packet.content() ); - queue_.nq(packet); - if(DEBUG) - System.out.println("srt: Done nq'ing.."); - - // go back to reading the socket now - } - // of for(;;) - } - // of method run -} diff --git a/java/apps/NexusII/src/socketWriterThread.java b/java/apps/NexusII/src/socketWriterThread.java deleted file mode 100644 index 395449b6a53..00000000000 --- a/java/apps/NexusII/src/socketWriterThread.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - $RCSfile$ - $Author$ - - Last Update: $Date$ - $Revision$ - - REVISION HISTORY: - $Log$ - Revision 1.1 1997/01/31 01:11:12 sumedh - Added the Nexus II source code files. - -# Revision 1.1 1996/12/07 06:27:38 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:09:22 rajeev -# Initial revision -# -# Revision 1.1 1996/12/02 06:02:24 rajeev -# Initial revision -# - -*/ -// The socketWriterThread is like a Consumer who reads from the write_q and -// puts it onto the socket. Thats it ... Big Deal. huh ! - -// This threads task is -// 1. Write things to SocketBuffer. -// 2. Ensure that Full Packets are sent -// 3. Read the packet off the queue - -//package NexusII.networking ; - -// get hold of java classes - -import java.io.* ; - -//import NexusII.client.* ; -//import NexusII.util.* ; - -public class socketWriterThread extends Consumer implements Runnable,consts -{ - DataOutputStream os_ ; - - // new constructor - // Pass the queue and outstream to the constructor - - public socketWriterThread(MT_Bounded_Queue q, DataOutputStream os) { - // call the super constructor - super(q); - os_ = os ; - } - - // This will just override the run method and thats it - // I want to have my own run ! - - public void run() { - // run indefinitely -- i am a daemon anyway - if(DEBUG) { - System.out.println("--- This is socketWriterThread --- \n"); - } - boolean bye_sent = false ; - while(!bye_sent) { - - // read the packet from the queue - dataPacket packet = (dataPacket) queue_.dq(); - if(DEBUG){ - System.out.println("socketWriterThread: I got something -- \n"); - } - - // read length bytes from packet - int len = packet.contentLength() ; - if(DEBUG) { - System.out.println("socketWriterThread: length is " + new Integer(len)); - } - - - int field_len = FIELD_LENGTH ; - - // Allocate storage for holding the fields - - byte[] packetHeader = new byte[PACKET_HEADER_LENGTH]; - byte[] packetBody = new byte[len] ; - - // Fill them - packet.bytize(packetHeader,packetBody); - - // put it on the wire now -- - - try { - os_.write(packetHeader,0,PACKET_HEADER_LENGTH); - } - catch (IOException e) { - // do something here - } - if(DEBUG){ - System.out.println("I wrote:" + new String(packetHeader,0)); - } - - try { - os_.write(packetBody,0,len); - } - catch (IOException e) { - // do something here - } - if(DEBUG){ - System.out.println("I wrote:" + new String(packetBody,0)); - } - // this is to handle if the user presses disconnect without leaving the - // room - if(packet.contentType().equalsIgnoreCase("QUIT")) - bye_sent = true ; - // go back to reading the queue now - } - // of for(;;) - } - // of method run - -} diff --git a/java/apps/NexusII/src/url_to_url.java b/java/apps/NexusII/src/url_to_url.java deleted file mode 100644 index 0fe08ab6db3..00000000000 --- a/java/apps/NexusII/src/url_to_url.java +++ /dev/null @@ -1,33 +0,0 @@ -// This method takes in a url and a prefix name and pulls that url across the -// network, stores it in a local file named prefix - -// for now it assumes that the url is an image only ! - -import java.net.* ; -import java.io.* ; -import java.awt.* ; -public class url_to_url { - Image im ; - - public url_to_url(URL url,String prefix) { - try { - im = (Image)url.getContent(); - } catch (IOException i) {} - String www_path = System.getProperty("www-path"); - String home_dir = System.getProperty("user.home"); - String dir = home_dir + www_path ; - System.out.println("web dir is this : " + dir); - - } - - public static void main(String[] argv) { - URL test = null ; - try { - test = new URL("http://www.cs.wustl.edu/~rajeev/images/sand.jpg"); - } catch ( MalformedURLException e) {} - - url_to_url t = new url_to_url(test,"root") ; - - } - -} diff --git a/java/apps/NexusII/start b/java/apps/NexusII/start deleted file mode 100755 index c699c96da60..00000000000 --- a/java/apps/NexusII/start +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/sh - -## This is an example script to launch the server. - -# the mywebaddress variable should point to a URL which is world-readable -# the mywebdir variable should point to the actual pathname of the URL -# which is specified by the mywebaddress variable -# The server needs to have write access to the mywebdir directory. -# Thus, the server saves images into the "mywebdir", and clients -# can access them via the "mywebaddress" URL. - -# the 222222 number is the port number on which the server is to be launched -# the same port number should appear in the html document containing -# the client applet (see start.html for an example) - -# while running the server, the ./classes should be part of the CLASSPATH. -# while running the client, the client classes as well as the awtCommand -# toolkit should be world-readable. (The awtcommand toolkit is included -# in this toolkit, under the classes directory.) - - -umask 022 -java -Dmywebaddress=http://cumbia.cs.wustl.edu/NexusII/tmp/ -Dmywebdir=/project/cumbia/sumedh/web/apache/root/NexusII/tmp/ NexusIIserver 222222 - - - - diff --git a/java/apps/NexusII/start.html b/java/apps/NexusII/start.html deleted file mode 100644 index cd591295b4a..00000000000 --- a/java/apps/NexusII/start.html +++ /dev/null @@ -1,3 +0,0 @@ -<applet code=NexusClientApplet.class width=550 height=500> - <param name=serverport value="222222"> -</applet> |