]> code.citadel.org Git - citadel.git/blobdiff - webcit/static/MultiUserChat102.java
* Replaced the Java chat with a new system based on IFRAME's and JavaScript
[citadel.git] / webcit / static / MultiUserChat102.java
index fe620bad4d33a429991cbe650c80337eb5a2377b..2a120c7544d7a0f31394ab130f62d947840d9eb3 100644 (file)
@@ -24,37 +24,37 @@ class ReceiveChat extends Thread {
        String MyName;
        StringTokenizer ST;
        MultiUserChat102 ParentMUC;
-       Label[] Linez = new Label[25];
+        Label[] Linez = new Label[25];
        int a;
-       
-       ReceiveChat(MultiUserChat102 muc, Panel t, wcCitServer s, String n) {
+
+        ReceiveChat(MultiUserChat102 muc, Panel t, wcCitServer s,
+                    String n) {
                TheArea = t;
                serv = s;
                MyName = n;
                ParentMUC = muc;
                serv.AddClientThread(this);
 
-               TheArea.setLayout(new GridLayout(25,1));
+               TheArea.setLayout(new GridLayout(25, 1));
 
-               for (a=0; a<25; ++a) {
+               for (a = 0; a < 25; ++a) {
                        Linez[a] = new Label(" ");
                        Linez[a].setBackground(Color.black);
                        Linez[a].setForeground(Color.black);
                        TheArea.add(Linez[a]);
-                       }
-
-               TheArea.validate();
+               } TheArea.validate();
 
-               }
+       }
 
        private void ScrollIt(String TheNewLine, Color NewLineColor) {
-               for (a=0; a<24; ++a) {
-                       Linez[a].setText(Linez[a+1].getText());
-                       Linez[a].setForeground(Linez[a+1].getForeground());
-                       }
+               for (a = 0; a < 24; ++a) {
+                       Linez[a].setText(Linez[a + 1].getText());
+                       Linez[a].setForeground(Linez[a + 1].
+                                              getForeground());
+               }
                Linez[24].setText(TheNewLine);
                Linez[24].setForeground(NewLineColor);
-               }
+       }
 
 
        public void run() {
@@ -62,7 +62,7 @@ class ReceiveChat extends Thread {
                int a;
 
                LastLineUser = "  ";
-               while(true) {
+               while (true) {
                        boof = serv.ServGets();
 
                        if (boof.equals("000")) {
@@ -70,83 +70,82 @@ class ReceiveChat extends Thread {
                                ParentMUC.dispose();
                                stop();
                                destroy();
-                               }
+                       }
 
 
                        ST = new StringTokenizer(boof, "|");
                        if (ST.hasMoreTokens()) {
                                cUser = ST.nextToken();
-                               }
-                       else {
+                       } else {
                                cUser = ":";
-                               }
+                       }
                        if (ST.hasMoreTokens()) {
                                cText = ST.nextToken();
-                               }
-                       else {
+                       } else {
                                cText = " ";
-                               }
+                       }
                        if (!cText.startsWith("NOOP")) {
                                if (!LastLineUser.equals(cUser)) {
                                        ScrollIt("", Color.black);
                                        ThisLine = cUser + ": ";
-                                       }
-                               else {
-ThisLine = "                                  ".substring(0, cUser.length()+2);
-                                       }
+                               } else {
+                                       ThisLine =
+                                           "                                  ".
+                                           substring(0,
+                                                     cUser.length() + 2);
+                               }
                                ThisLine = ThisLine + cText;
                                UserColor = Color.green;
                                if (cUser.equals(":")) {
                                        UserColor = Color.red;
-                                       }
+                               }
                                if (cUser.equalsIgnoreCase(MyName)) {
                                        UserColor = Color.yellow;
-                                       }
+                               }
                                ScrollIt(ThisLine, UserColor);
                                LastLineUser = cUser;
-                               }
                        }
                }
-
        }
 
+}
 
 
 
 
-public class MultiUserChat102
-       extends Frame {
 
-wcCitServer serv;
-ReceiveChat MyReceive;
-Panel AllUsers;
-TextField SendBox;
-wcchat ParentApplet;
+public class MultiUserChat102 extends Frame {
 
+       wcCitServer serv;
+       ReceiveChat MyReceive;
+       Panel AllUsers;
+       TextField SendBox;
+       wcchat ParentApplet;
 
-MultiUserChat102(wcCitServer PrimaryServ, wcchat P) {
-       super ("Multiuser Chat");
 
-       String boof;
+        MultiUserChat102(wcCitServer PrimaryServ, wcchat P) {
+               super("Multiuser Chat");
 
-       /* Set up a new server connection as a piggyback to the first. */
-       serv = PrimaryServ;
-       ParentApplet = P;
+               String boof;
 
-       resize(600,400);
-       setLayout(new BorderLayout());
+               /* Set up a new server connection as a piggyback to the first. */
+                serv = PrimaryServ;
+                ParentApplet = P;
 
-       boof = "This is the buffer before the chat command.";
-       serv.ServPuts("CHAT");
-       boof = serv.ServGets();
+                resize(600, 400);
+                setLayout(new BorderLayout());
 
-       if (boof.charAt(0) != '8') {
-               add("Center", new Label("ERROR: " + boof) );
-               show();
+                boof = "This is the buffer before the chat command.";
+                serv.ServPuts("CHAT");
+                boof = serv.ServGets();
+
+               if (boof.charAt(0) != '8') {
+                       add("Center", new Label("ERROR: " + boof));
+                       show();
                }
 
-       else {
-               DoChat(PrimaryServ.GetUserName());
+               else {
+                       DoChat(PrimaryServ.GetUserName());
                }
 
        }
@@ -155,44 +154,54 @@ MultiUserChat102(wcCitServer PrimaryServ, wcchat P) {
 /*
  * Do the actual chat stuff
  */
-private void DoChat(String MyName) {
-       String boof;
+       private void DoChat(String MyName) {
+               String boof;
 
-       SendBox = new TextField(80);
+               SendBox = new TextField(80);
 
-       AllUsers = new Panel();
+               AllUsers = new Panel();
 
-       add("Center", AllUsers);
-       add("South", SendBox);
-       show();
+               add("Center", AllUsers);
+               add("South", SendBox);
+               show();
 
-       MyReceive = new ReceiveChat(this, AllUsers, serv, MyName);
-       MyReceive.start();
+               MyReceive = new ReceiveChat(this, AllUsers, serv, MyName);
+               MyReceive.start();
 
-       SendBox.requestFocus();
+               SendBox.requestFocus();
        }
 
 
-public boolean handleEvent(Event evt) {
-       int LastSpace;
+       public boolean handleEvent(Event evt) {
+               int LastSpace;
 
-       if ( (evt.target == SendBox) && (evt.id == Event.ACTION_EVENT) ) {
-               serv.ServPuts(SendBox.getText());
-               SendBox.setText("");
+               if ((evt.target == SendBox)
+                   && (evt.id == Event.ACTION_EVENT)) {
+                       serv.ServPuts(SendBox.getText());
+                       SendBox.setText("");
                }
 
-       else if (evt.target == SendBox) {
-               if ( SendBox.getText().length() + serv.GetUserName().length() > 78 ) {
-                       LastSpace = SendBox.getText().lastIndexOf(' ');
-                       if (LastSpace < 0) {
-                               serv.ServPuts(SendBox.getText());
-                               SendBox.setText("");
-                               }
-                       else {
-                               serv.ServPuts(SendBox.getText().substring(0,LastSpace));
-                               SendBox.setText(SendBox.getText().substring(LastSpace));
-                               if (SendBox.getText().charAt(0) == ' ') {
-                                       SendBox.setText(SendBox.getText().substring(1));
+               else if (evt.target == SendBox) {
+                       if (SendBox.getText().length() +
+                           serv.GetUserName().length() > 78) {
+                               LastSpace =
+                                   SendBox.getText().lastIndexOf(' ');
+                               if (LastSpace < 0) {
+                                       serv.ServPuts(SendBox.getText());
+                                       SendBox.setText("");
+                               } else {
+                                       serv.ServPuts(SendBox.getText().
+                                                     substring(0,
+                                                               LastSpace));
+                                       SendBox.setText(SendBox.getText().
+                                                       substring
+                                                       (LastSpace));
+                                       if (SendBox.getText().charAt(0) ==
+                                           ' ') {
+                                               SendBox.setText(SendBox.
+                                                               getText().
+                                                               substring
+                                                               (1));
                                        }
                                }
                        }