This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
project.txt
201 lines (168 loc) · 8.7 KB
/
project.txt
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
CSC 460 - Fall 2010 Project
Interactive Real-time Multi-window Chat
Time-stamp: <2010-10-27 12:22:31 shade>
Assume an 80x24 window. It's possible to query the size of the actual
terminal window, and to be notified when the terminal is resized, but
that would have to be implemented in the client (because different
clients could have different terminal sizes). We want the clients to
be dumb and have the server just tell them what to update, which will
be easier if the server can assume that all terminals are the same
size. You can implement arbitrary terminal sizes as an extension if
you want.
ARCHITECTURE
The server must be multithreaded, with one thread per client
connection. You may use additional threads if you you want. The
updates must be as close to real-time as possible, and the time
updates must be as accurate as possible. You should design your
wire protocol to minimize network traffic, keeping in mind that
the minimum network packet size is 64 bytes. (So it's better to
send one 60-byte message than 10 six-byte messages.)
You will need to use alarm for the time updates (ualarm is only
good for sub-second time intervals). For all other updates, it's
probably better to use semaphores or some other inter-thread
communication mechanism.
UNDER NO CIRCUMSTANCES MAY THE SERVER OR CLIENT BUSY-WAIT!
SCREEN LAYOUT
See below.
Each user window must display the amount of time the user has been
connected in minutes, to the nearest tenth (a tenth of a minute is
six seconds, of course): something like "12.4m"
The program status window must also display the number of minutes
that the chat has been active, using the same format. It must
also display the total amount of "traffic", rounded to the nearest
kilobyte. You can use a metric kilo (10^3), or a binary kilo
(2^10). "Traffic" is some reasonable measure of the amount of
data transferred: it could be total number of keypresses, total
bytes sent to the transcript window (for one user), total network
traffic (for one user), etc.
KEYS
A design goal is that the interface should not require any special
keys other than Ctrl, and all functionality must be available
without entering special commands in the text window. If you want
to allow the use of arrow keys, home/end, pgup/pgdn, function
keys, etc., you can do so as an extension: all such keys are
represented by a character sequence starting with Ctrl-[ (ESC).
REQUIRED COMMAND KEYS
Ctrl-^: (Ctrl-6) deep-six!
Ctrl-]: resume transcript at end
Ctrl-G: gaudy! toggle gaudy (emphasized) text
Ctrl-H: (BKSP) delete previous char
Ctrl-J: (ENTER)
Ctrl-L: lurk!
Ctrl-M: (RETURN) treat the same as Ctrl-J
Ctrl-N: scroll down to next page in transcript
Ctrl-P: scroll up to previous page in transcript
Ctrl-Q: quit the program
Ctrl-U: delete to beginning of text
Ctrl-W: delete previous word (including any trailing spaces)
Ctrl-Y: yell!
OPTIONAL EDITING KEYS
You don't have to implement any of these, but you can't use them
for any other purpose.
Ctrl-@: (Ctrl-SPC) toggle marking text
Ctrl-A: go to beginning of text
Ctrl-B: go backward one char
Ctrl-C: copy marked region and turn off marking
Ctrl-D: delete char at cursor
Ctrl-E: go to end of text
Ctrl-F: go forward one char
Ctrl-K: kill to end of text
Ctrl-R: reverse (backward) search for next character typed
Ctrl-S: (forward) search for next character typed
Ctrl-V: paste
Ctrl-X: cut marked region and turn off marking
Searching for Ctrl-@/Ctrl-SPC (a null character) is equivalent to
searching for SPC; searching for SPC always succeeds, going to the
beginning or end of the line if necessary. So Ctrl-S Ctrl-SPC is
the same as "go to next word", and Ctrl-R Ctrl-SPC is the same as
"go to previous word".
RESERVED KEYS (FOR EXTENSIONS)
Ctrl-[ (ESC): prefix for function keys, arrow keys, etc.
Ctrl-I (TAB)
Ctrl-O, Ctrl-T, Ctrl-Z, Ctrl-\, Ctrl-_
Client sends NAME/MAJOR-VERSION/MINOR-VERSION to server on connect,
server responds with similar, so that extra features can be enabled.
WINDOW LAYOUT (horizontal width shown is 50% of normal)
P = 40x3 program info bar (name, version, etc.)
* = 40x23 linear transcript window; scrolls vertically
S = 40x2 user status/help bar
E = 80x1 user editing window (scrolls horizontally)
0-9 = 20x2 real-time status/typing windows, one per user
- = separator lines
********************PPPPPPPPPPPPPPPPPPPP
********************PPPPPPPPPPPPPPPPPPPP
********************PPPPPPPPPPPPPPPPPPPP
********************
********************0000000000----------
********************00000000005555555555
********************----------5555555555
********************1111111111----------
********************11111111116666666666
********************----------6666666666
********************2222222222----------
********************22222222227777777777
********************----------7777777777
********************3333333333----------
********************33333333338888888888
********************----------8888888888
********************4444444444----------
********************44444444449999999999
********************----------9999999999
********************
********************SSSSSSSSSSSSSSSSSSSS
********************SSSSSSSSSSSSSSSSSSSS
********************SSSSSSSSSSSSSSSSSSSS
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
DEEP-SIX MODE
Entered by pressing Ctrl-^ (or Ctrl-6, which is the same key).
Displays a pop-up window listing all online users who you have not
deep-sixed already, plus a message saying to press any other key
to exit. The users are numbered 0-9. Pressing a number
corresponding to a user adds a "deep-six" vote for that user and
adds a message to the transcript, like "bob deep-sixed larry".
Pressing any other key does not send a vote. Any keypress closes
the window. Deep-six votes are displayed in the status line for
each user. If you quit the program, all deep-six votes you made
are removed. If a user gets deep-six votes equal to a majority
(more than half) of the users online, that user is ejected. A
line such as "larry has been ejected" is added to the transcript.
The ejected user sees a pop-up window that lasts five seconds
notifying him or her of ejection, then the program terminates;
during the five-second period no keypresses are recognized.
GAUDY MODE
Toggled by pressing Ctrl-G. Displays text in "gaudy" mode, which
is meant to represent boldfacing or emphasis. To represent gaudy
mode in a string, I suggest using the ASCII STX (start of text)
and ETX (end of text) characters, which have codes 2 and 3. When
you display a string, don't display these characters, but toggle
gaudy display. When editing, backspacing over an ETX should also
delete the character preceding it; when backspacing over any other
character, see if an STX precedes it, and if so, delete it too.
You can decide how to display gaudy text, but it must be readable.
SCROLLING THE TRANSCRIPT
After hitting a scroll key (Ctrl-N or Ctrl-P), the transcript is
"frozen"; new transcript lines must be accepted from the server,
but they are not displayed in the transcript window. The
status/help window must display that Ctrl-] resumes the
transcript. After pressing a scroll key, if another scroll key is
not pressed within five seconds, the transcript automatically
resumes.
LURK MODE
Entered by pressing Ctrl-L. Displays a pop-up window covering the
editing area that says "Lurking..." and that says you can press
Ctrl-L to quit lurking or Ctrl-Q to quit the program. While
lurking, all displays continue to update, but you can't do
anything. Your status changes to LURKING.
YELL MODE
Entered by pressing Ctrl-Y. Displays a pop-up window with a list
of predefined messages, labelled A, B, C, ..., Z, plus a line
saying to press any other key to exit. (Thus there can be at most
26 messages, but you don't have to have that many. The messages
are defined by the server, not the user.) Pressing the letter
corresponding to a message closes the window and immediately sends
that message to the transcript, without changing your status or
editing area. Pressing any other key closes the window without
sending anything. [Use your creativity in designing the messages,
but they must include at least one phrase that expresses agreement
("I agree", "ditto", etc.) and one that expresses disagreement ("I
disagree", "no way", etc.) Keep the messages PG-13.]