]> gb7djk.dxcluster.net Git - spider.git/blob - spider-web/spiderclient.java
remove \r from help files anyway
[spider.git] / spider-web / spiderclient.java
1 import java.awt.*;
2 import java.applet.*;
3 import java.io.*;
4 import java.net.*;
5
6
7 public class spiderclient extends Applet {
8
9         public void init() {
10                 String p;
11         
12                 cf = new spiderframe(this);
13                 cf.resize(800,600);
14                 
15                 p = getParameter("CALL");
16                 if (p != null) cf.setCall(p);
17                 
18         p = getParameter("PASSWORD");
19         if (p != null) cf.setPassword(p);
20         
21                 p = getParameter("FULLNAME");
22                 if (p != null) cf.setFullname(p);
23
24                 p = getParameter("HOSTNAME");
25                 if (p != null) cf.setHostname(p);               
26
27                 p = getParameter("PORT");
28                 if (p != null) cf.setPort(p);
29
30                 p = getParameter("CHANNEL");
31                 if (p != null) cf.setChannel(p);
32
33                 Beep = getAudioClip(getCodeBase(), "ding.au");
34                 // cf.login();
35                 cf.resize(655, 380);
36                 
37                 cf.show();
38         }
39         
40         public void doconnect() {
41                 try {
42                         s = new Socket(cf.getHostname(), Integer.parseInt(cf.getPort()));
43                         out = new PrintStream(s.getOutputStream());
44                         in = new DataInputStream(s.getInputStream());
45                         cf.initPrintStream(out);
46                 
47                         listener = new StreamListener(cf, in);
48                         
49                         out.println(cf.getCall());
50
51                         if(cf.getPassword().length() > 0) {
52                 out.println(cf.getPassword());
53             }
54
55                         // out.println(cf.getFullname());
56                 }
57                 catch (IOException e) { 
58                         InfoDialog id = new InfoDialog(cf, "Error", e.toString());
59                 }
60                 cf.connected();
61                 Beep.play();
62         }
63
64         public void dodisconnect() {
65                 try {
66                         s.close();
67                 }
68                 catch (IOException e) { 
69                         InfoDialog id = new InfoDialog(cf, "Error", e.toString());
70                 }
71                 cf.disconnected();
72                 Beep.play();
73         }
74
75         void beep() {
76                 Beep.play();
77         }
78
79         private Socket s = null;
80         private PrintStream out;
81         private DataInputStream in;
82         private StreamListener listener;
83         
84         private AudioClip Beep; 
85
86         spiderframe cf;
87 }
88
89 class StreamListener extends Thread {
90         DataInputStream in;
91         spiderframe cf;
92         
93         public StreamListener(spiderframe cf, DataInputStream in) {
94                 this.in = in;
95                 this.cf = cf;
96                 this.start();
97         }
98         
99         public void run() {
100                 String line;
101                                 
102                 try {
103                         for (;;) {
104                         line = in.readLine();   
105                         
106                         // schrieb nur jede 2te zeile , deswegen //
107                         // line = in.readLine();
108                         
109                         
110                         
111                         
112                         
113                         if (line == null) break;
114                                 cf.setText(line);
115                         }
116                         cf.disconnected();
117                 }
118                 catch (IOException e) {
119                         cf.setText(e.toString());
120                         cf.disconnected();
121                 }
122                 
123                 finally { cf.setText("Connection closed by server."); }
124         }
125 }