Using the Blackboard to Transfer Machine Information from SiteRemote to SiteKiosk Windows

A team on the remote management solution SiteRemote enables you to manage your SiteKiosk machines by assigning them to folders and tags. You can also assign address information like the location of the machine or the responsible maintenance person. This information can also come in handy on the client machines. For example you may use it to display different content based on the location address or the assignment to a specific folder or tag. This also means, that whenever you change this information on the server you can directly make use of that change on the client.

Let's find out how to get the information from the SiteRemote server. We will use the SiteKiosk Object Model inside an HTML page running in the SiteKiosk Windows browser. The SiteKiosk Object Model provides the ReadBlackboardAsString method. We will use that method to get the name of the SiteRemote team the machine is registered to, the SiteRemote display name of the machine, the folder and tags the machine is associated to and the address information assigned to the machine. For our example the setup lools like this:

The ReadBlackboardAsString method accepts a string as parameter that specifies the requested information (see the Remarks part here for further information) as shown in this example excerpt:

//Get the name of the SiteRemote team the machine is registered with.
document.getElementById("teamname").innerHTML = SiteRemotePlugin.ReadBlackboardAsString('StC.TeamInfo.Name');
//Get the display name of the machine in the SiteRemote team it is registered with.
document.getElementById("machinename").innerHTML = SiteRemotePlugin.ReadBlackboardAsString('StC.MachineInfo.Name');
//Get the folders and tags the machine is part of.
document.getElementById("groupstags").innerHTML = SplitBlackBoardStrings(SiteRemotePlugin.ReadBlackboardAsString('StC.MachineInfo.LocationInTreeview'));
//Get address information for the machine, e.g. location, maintenance contact.
document.getElementById("supportinfo").innerHTML = SplitBlackBoardStrings(SiteRemotePlugin.ReadBlackboardAsString('StC.MachineInfo.SupportInfo'));

The method returns a string with the SiteRemote blackboard information. Be aware that the string is in JSON format. You can either handle it as a normal string, just like in the above example, which is why the information for the group/tag membership and the address information is processed in an additional method (see the full example code below to see the code of that method) that splits the string at every comma. You can also work with the string in JSON format, for which you may need to add additonal script, see the Examples part here for more information.

The full example code we can build around the reading of the SiteRemote blackboard looks like this:

<html>
	<head>
		<title>SiteKiosk Blackboard Example</title>
		
		<style type="text/css">
			div { color:black; font-style:arial; font-size:18px; }
			span { color:red; font-style:arial; font-size:24px; }
		</style>

		<script type="text/javascript">
			window.external.InitScriptInterface();
			
			SiteRemotePlugin = SiteKiosk.Plugins("SiteRemote");
			
			//First check if the machine is registered with SiteRemote.
			if (SiteRemotePlugin.IsRegistered){
				//Registered. Trigger the initial blackboard request. Note: the first request will most likely come back empty.
				ReadSiteRemoteBlackboard();
			}
			else{
				//Not registered. Show message on screen.
				document.getElementById("registered").stlye.display = "none";
				document.getElementById("notregistered").stlye.display = "inline";
			}
			
			function ReadSiteRemoteBlackboard(){
				try{
					//Get the name of the SiteRemote team the machine is registered with.
					document.getElementById("teamname").innerHTML = SiteRemotePlugin.ReadBlackboardAsString('StC.TeamInfo.Name');
					//Get the display name of the machine in the SiteRemote team it is registered with.
					document.getElementById("machinename").innerHTML = SiteRemotePlugin.ReadBlackboardAsString('StC.MachineInfo.Name');
					//Get the folders and tags the machine is part of.
					document.getElementById("groupstags").innerHTML = SplitBlackBoardStrings(SiteRemotePlugin.ReadBlackboardAsString('StC.MachineInfo.LocationInTreeview'));
					//Get address information for the machine, e.g. location, maintenance contact.
					document.getElementById("supportinfo").innerHTML = SplitBlackBoardStrings(SiteRemotePlugin.ReadBlackboardAsString('StC.MachineInfo.SupportInfo'));
				}catch(e){
					//Blackboard information is not yet available, try again in 10 seconds.
					window.setTimeout("ReadSiteRemoteBlackboard()", 10000);
				}
			}
			
			function SplitBlackBoardStrings(blackboardstring){
				//Split the Blackboard string for better readability.
				var blackboardstringelements = blackboardstring.split(",");
				var composedelements = "";
				
				for (var i = 0; i < blackboardstringelements.length; i++){
					composedelements += blackboardstringelements[i] + "<br />";
				}
				
				return composedelements;
			}
		</script>
	</head>
	<body>
		<div id="registered" style="display:inline;">
			This machine is part of the SiteRemote Team <span id="teamname">[Information not yet available. Please wait.]</span> and 
			its display name on the SiteRemote server is <span id="machinename">[Information not yet available. Please wait.]</span>.
			<br /><br />
			The machine is assigned to the following groups and tags:
			<br />
			<span id="groupstags">[Information not yet available. Please wait.]</span>
			<br /><br />
			These addresses are available for the machine:
			<br />
			<span id="supportinfo">[Information not yet available. Please wait.]</span>
		</div>
		<div id="notregistered" style="display:none;">
			This machine is not registered with SiteRemote!
		</div>
	</body>
</html>

If you save the example code as an HTML page and place it in the html subfolder of your SiteKiosk installation and then configure SiteKiosk to use it as a start page you will get output similar to this:

Note that of course this requires that you register your SiteKiosk Windows client with a SiteRemote server and assign tags and address information to it. As you can see above the address information may include empty fields, if those values have not been provided when creating the address information. You can sort through those with standard Javascript string handling procedures.

For further reading you may want to have a look at the AttachBlackboardListener and DetachBlackboardListener methods, that will enable you to automatically and continously listen for changes to blackboard information on the SiteRemote server, so that the client can immediately react to those changes.