service {
const html Logon =
Welcome to The Chat Room
Please enter your on-line name:
;
const html Update =
The Chat Room Service
Messages so far:
<[msg0]>
<[msg1]>
<[msg2]>
<[msg3]>
<[msg4]>
<[msg5]>
Your new message:
Quit now
;
const html ByeBye =
Thanks for using The Chat Room
You made <[conns]> connections
and wrote <[msgs]> messages.
;
string msg0,msg1,msg2,msg3,msg4,msg5;
session Chat() {
string name,msg,quit;
int connections, written;
connections = 0;
written = 0;
quit = "no";
show Logon receive [name = name];
while (quit!="yes") {
show plug Update[msg0 = msg0,
msg1 = msg1,
msg2 = msg2,
msg3 = msg3,
msg4 = msg4,
msg5 = msg5]
receive[msg = msg, quit = quit];
connections = connections+1;
if (msg!="") {
written = written+1;
msg0 = msg1;
msg1 = msg2;
msg2 = msg3;
msg3 = msg4;
msg4 = msg5;
msg5 = name + "> " + msg;
}
}
exit plug ByeBye[conns = connections,
msgs = written];
}
}