<> <> <<>> 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; <> <<>> Log.RegisterWhereToReport[ReportBluejay, $Bluejay]; Log.Report["Jay Smarts Initialized", $Bluejay]; BluejayUtils.Initialize[]; <> BJ.jayShh _ Thrush.unencrypted; BJ.interfaceIsImported_TRUE; <> 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; <<>> <> 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; -- <> 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_BJ.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"]; }.