BluejaySmartsInitLocalImpl.mesa
Last modified by D. Swinehart, April 9, 1984 7:45:08 am PST
DIRECTORY
BluejaySmarts,
BluejayUtils USING [ Initialize, Uninitialize ],
IO,
Jukebox  USING [ CloseJukebox, CreateJukebox, Error, 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, 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!
Jukebox.Error=> IF reason= NoJukebox THEN { BJ.haveJuke←FALSE; CONTINUE; }];
IF ~BJ.haveJuke THEN {
Jukebox.CreateJukebox[jukeboxName, 5000, 100];
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 GOTO InitFailed; -- <<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"];
}.