blob: 64e6da66122f0138962b44645a2a640fa3f613d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*
$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
|