EchoProtocol.Mesa
Last Edited by: Spreitzer, March 20, 1985 11:42:33 am PST
DIRECTORY IO, IOClasses, Process, Protocols, Rope;
EchoProtocol: CEDAR PROGRAM
IMPORTS IOClasses, Process, Protocols
= {OPEN Protocols;
echo: Protocol ← NEW [ProtocolRep ← [
name: "Echo",
Connect: Connect,
Disconnect: Disconnect
]];
Connect: PROC
[
serverName: ROPE,
fromClient, toClient: IO.STREAM,
noteDisconnect: PROC [clientData: REF ANY] ← NIL,
clientData: REF ANYNIL,
login: BOOLFALSE]
RETURNS [c: Conversation] =
{
c ← NEW [ConversationRep ← [protocol: echo, noteDisconnect: noteDisconnect, clientData: clientData, data: NIL]];
TRUSTED {Process.Detach[FORK IOClasses.Copy[from: fromClient, to: toClient]]};
};
Disconnect: PROC [c: Conversation] = {
IF c.noteDisconnect # NIL THEN c.noteDisconnect[c.clientData]};
Protocols.RegProtocol[echo];
}.