]> code.citadel.org Git - citadel.git/blob - webcit/static/wcchat.java
184a9aa6ef2c48d2c52c11e2f57eed54f551e6bb
[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 = "uncnsrd.mt-kisco.ny.us";
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                  */
29                 if (getParameter("host") != null) {
30                         ServerHost = getParameter("host");
31                         }
32
33                 /* The 'port' parameter tells the client to look on a
34                  * nonstandard port for the Citadel server.
35                  */
36                 if (getParameter("port") != null) {
37                         ServerPort = 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 = serv.ServTrans("PASS "+getParameter("password"));
50                         if (buf.charAt(0) == '2') {
51                                 serv.SetUserName(wcCitUtil.Extract(buf.substring(4), 0));
52                                 buf = serv.ServTrans("GOTO "+getParameter("roomname"));
53                                 new MultiUserChat102(serv, this);
54                                 }
55                         }
56                 else {
57                         System.out.println("ooops...");
58                         }
59                 }
60
61 }