]> code.citadel.org Git - citadel.git/blob - webcit/static/wcchat.java
* Replaced the Java chat with a new system based on IFRAME's and JavaScript
[citadel.git] / webcit / static / wcchat.java
1 /*
2  * Java client for Citadel/UX
3  * Copyright (C) 1997 by Art Cancro - All Rights Reserved
4  *
5  * This module is designed to be able to run either as an application or
6  * as an applet.
7  */
8
9 import java.applet.*;
10
11 public class wcchat extends Applet {
12
13         String ServerHost = "uncensored.citadel.org";
14         int ServerPort = 504;
15
16         public void init() {
17
18                 /* Unless overridden, the Citadel server is expected to be
19                  * the same as the applet host.  In most cases this is all
20                  * that's allowed anyway.
21                  */
22                 if (getDocumentBase() != null) {
23                         ServerHost = getDocumentBase().getHost();
24                 }
25
26                 /* The 'host' parameter tells the client to look somewhere other
27                  * than the applet host for the Citadel server.
28                  */ if (getParameter("host") != null) {
29                         ServerHost = getParameter("host");
30                 }
31
32                 /* The 'port' parameter tells the client to look on a
33                  * nonstandard port for the Citadel server.
34                  */
35                 if (getParameter("port") != null) {
36                         ServerPort =
37                             Integer.parseInt(getParameter("port"));
38                 }
39
40         }
41
42         public void start() {
43                 wcCitServer serv = new wcCitServer();
44                 String buf = null;
45
46                 serv.AttachToServer(ServerHost, ServerPort);
47                 buf = serv.ServTrans("USER " + getParameter("username"));
48                 if (buf.charAt(0) == '3') {
49                         buf =
50                             serv.ServTrans("PASS " +
51                                            getParameter("password"));
52                         if (buf.charAt(0) == '2') {
53                                 serv.SetUserName(wcCitUtil.
54                                                  Extract(buf.substring(4),
55                                                          0));
56                                 buf =
57                                     serv.ServTrans("GOTO " +
58                                                    getParameter
59                                                    ("roomname"));
60                                 new MultiUserChat102(serv, this);
61                         }
62                 } else {
63                         System.out.println("ooops...");
64                 }
65         }
66
67 }