BluejaySmartsInitLocalImpl.mesa
Last modified by D. Swinehart, December 28, 1983 10:17 pm
DIRECTORY
BluejaySmarts,
BluejayUtils USING [ Initialize, Uninitialize ],
FS USING [ Error ],
IO,
Jukebox USING [ CloseJukebox, CreateJukebox, OpenJukebox ],
Names USING [ OwnNetAddress ],
PupDefs USING [ PupSocket ],
Log USING [ FindWhere, RegisterWhereToReport, Problem, Report, WhereProc ],
ThPartyPrivate USING [ RegisterLocal ],
ThParty USING [ CreateParty, Enable, RegisterClone ],
Thrush USING [ ConvEvent, ConversationHandle, nullHandle, PartyHandle, ROPE, SHHH, SmartsHandle, unencrypted ],
ThSmarts,
ThSmartsRpcControl USING [ InterfaceRecord, NewInterfaceRecord ],
Commander USING [ CommandProc, Register ],
UserProfile USING [ Token ],
VoiceStream USING [ Handle ]
;
BluejaySmartsInitLocalImpl:
CEDAR PROGRAM
IMPORTS BluejaySmarts, BluejayUtils, FS, Jukebox, Names, Log, ThParty, ThPartyPrivate, ThSmarts, ThSmartsRpcControl, Commander, UserProfile = {
OPEN BJ: BluejaySmarts, IO;
PartyHandle: TYPE = Thrush.PartyHandle;
SHHH: TYPE = Thrush.SHHH;
SmartsHandle: TYPE = Thrush.SmartsHandle;
JayInfo: TYPE = BJ.JayInfo;
JayInfoBody: TYPE = BJ.JayInfoBody;
InitJay:
PROC[ numTrunks:
NAT ] =
TRUSTED {
partyID: Thrush.PartyHandle;
smartsID: Thrush.SmartsHandle;
clonePartyID: Thrush.PartyHandle;
thrushInstance: Thrush.
ROPE=
UserProfile.Token[key: "ThrushClientServerInstance", default: "Morley.Lark"];
jukeboxName: Thrush.
ROPE =
UserProfile.Token[key: "BluejayJukeboxName", default: "Test.Jukebox"];
smartsInterface: ThSmartsRpcControl.InterfaceRecord;
info: BJ.JayInfo;
Export ThSmarts Interface
Log.RegisterWhereToReport[ReportBluejay, $Bluejay];
Log.Report["Jay Smarts Initialized", $Bluejay];
BluejayUtils.Initialize[];
Get encryption taken care of
BJ.jayShh ← Thrush.unencrypted;
BJ.interfaceIsImported←
TRUE;
Initialize anything that has to be set up on the Jay side.
BJ.haveJuke←TRUE;
BJ.handle ← Jukebox.OpenJukebox[jukeboxName!
FS.Error=>IF error.group=user THEN { BJ.haveJuke←FALSE; CONTINUE; }];
IF ~BJ.haveJuke
THEN {
Jukebox.CreateJukebox[jukeboxName, 5000, 100!FS.Error=>
IF error.group=user THEN {Log.Report[error.explanation, $Bluejay];GOTO InitFailed;}];
BJ.handle ← Jukebox.OpenJukebox[jukeboxName];
};
BJ.haveJuke←TRUE;
Get Jay Parties
FOR i:
NAT
IN [0..numTrunks)
DO
partyID←ThParty.CreateParty[type: recording, rName: NIL];
IF partyID=Thrush.nullHandle THEN EXIT;
IF i=0
THEN {
clonePartyID ← partyID;
smartsInterface ← ThSmartsRpcControl.NewInterfaceRecord[];
smartsInterface.Progress ← ThSmarts.Progress;
smartsID ← ThPartyPrivate.RegisterLocal[
partyID: partyID, interface: smartsInterface,
properties: [x: voiceTerminal[machine: Names.OwnNetAddress[]]]];
}
ELSE smartsID ← ThParty.RegisterClone[shh: BJ.jayShh, partyID: partyID, clonePartyID: clonePartyID];
IF smartsID=Thrush.nullHandle THEN EXIT; -- <<try to delete the Party?>>
IF ThParty.Enable[shh: BJ.jayShh, smartsID: smartsID]#success THEN ERROR; -- <<!!!!!>>
info←NEW[JayInfoBody ← [smartsID: smartsID, partyID: partyID, shh: BJ.jayShh]];
BJ.infos[BJ.numParties]←info;
BJ.smartses[BJ.numParties]←smartsID;
BJ.numParties𡤋J.numParties+1;
ENDLOOP;
EXITS
InitFailed => {
Log.Problem["Bluejay initialization failed", $Bluejay];
BluejayUtils.Uninitialize[];
IF BJ.haveJuke THEN BJ.handle ← Jukebox.CloseJukebox[BJ.handle!ANY=>CONTINUE];
};
};
ReportBluejay: Log.WhereProc =
TRUSTED {
s←Log.FindWhere[$System, NIL];
};
*************** Initialization ***************
JayCmd: Commander.CommandProc = TRUSTED { InitJay[5]; };
Commander.Register["Jay", JayCmd, "Start Bluejay server"];
}.