Protocols:
CEDAR
DEFINITIONS = {
ROPE: TYPE = Rope.ROPE;
Protocol: TYPE = REF ProtocolRep;
ProtocolRep:
TYPE =
RECORD [
name: ROPE,
Instantiate: PROC [client: Client, logFileName: ROPE ← NIL] RETURNS [c: Conversant],
StartConnect: PROC [c: Conversant, serverName: ROPE, login: BOOL ← FALSE],
StartDisconnect: PROC [c: Conversant, verbosely: BOOL ← TRUE],
GiveUp:
PROC [c: Conversant, verbosely:
BOOL ←
TRUE],
Aborts while connecting or disconnecting.
SetOnLine: PROC [c: Conversant, onLine: BOOL],
protocolData: REF ANY ← NIL
];
Client: TYPE = REF ClientPrivate;
ClientPrivate:
TYPE =
RECORD [
fromClient, toClient: IO.STREAM,
type: ClientType,
clientData: REF ANY ← NIL
];
ClientType: TYPE = REF ClientTypePrivate;
ClientTypePrivate:
TYPE =
RECORD [
NoteState: PROC [c: Conversant] ← NIL,
typeData: REF ANY ← NIL
];
Conversant: TYPE = REF ConversantPrivate;
ConversantPrivate:
TYPE =
RECORD [
protocol: Protocol,
client: Client,
state: State ← [FALSE, disconnected],
serverName: ROPE ← NIL,
fromServer: IO.STREAM ← NIL,
conversantData: REF ANY ← NIL
];
State:
TYPE =
RECORD [
onLine: BOOL,
connectivity: Connectivity
];
Connectivity: TYPE = {disconnected, connecting, connected, disconnecting};
GetProtocol: PROC [name: ROPE] RETURNS [p: Protocol];
RegProtocol: PROC [p: Protocol];
}.