What is it all about? – Remote objects and sandboxes
HotForestGreen takes two base concepts into the design:
- Remote Objects – Which can be shared over an Application Cluster and can update each other when data changes.
- SandBoxes – Which contains and isolates specific parts of the Application Cluster
What has been created?
The first test has been relatively simple.
There are two applications:
- The Test Server/Client – Which starts a HotForestGreen Server and initiates a SandBox
- The Test Client – Which creates connects to any Server, instantiates a new Remote Object and sends the update to the Sandbox
What has been tested?
- Initiating the Server – Making sure we can connect to something
- Initiating a SandBox – Allowing us to share objects
- Responding to the “SandBox Found” callback – On the Test Client and immediately:
- Creating a Remote Object – For testing purposes
- Sending a Remote Object Data Update – To all the other clients connected to that SandBox
- Receiving the Remote Object Data Update – On the Test Server/Client
- Parsing the data – From the Update to a (new) Remote Object on the Test Server/Client
What to make of this?
When you create a Application Cluster, your “data glue” between all the instances of your application are your Remote Objects.
- Your Remote Clients are connected – Your Remote Clients have a TCP/IP connection to your network and are connected to one or more HotForestGreen Servers
- Registered to the same SandBox – Your Remote Objects are registered to the same Sandbox
What to do with this?
There are many applications possible.
The next steps on my side will be to build three proof of concepts:
- Remote Mouse / Remote Keyboard – Using another computer or a tablet you can manipulate the mouse and keyboard on the Remote computer
- Change the color of a LCD-screen – Using Remote Objects that represent the screen of a computer, you can change the color of screens and create a light show
- Browsing the web using another computer – Using another computer, you can insert websites and browse the web
And what about Database Access?
The next series of tests will be to access and distribute data from one or more databases.
The basic parts: retrieving, changing and adding data via the HotForestGreen Framework have already been tested. The next step is to create a simple application that shows a list of items you can edit and which will automatically update on all computers running the Client.
The lines of code used to test the framework
Setting up the server:
// Define the port we will run on int port = 821; // Create and start the Socket Server SocketServer SS = new SocketServer(null); SS.startSocketServer(port); // Connect to the sandbox ApplicationSandBox.connectToSandBox("sandBox", port, onconnected); // Register the Remote Object "User" to the SandBox, using a shared alias User.registerToSandbox("sandBox","user",typeof(User));
private void onconnected(object retObj, EventArgs ard) { // Nothing for now }
// Define the port we want to connect to int port = 821; // Connect to the sandbox "sandBox" ApplicationSandBox.connectToSandBox("sandBox", port, onconnected); // Register the Remote Object "User" to the SandBox "sandBox" // to send and receive updates User.registerToSandbox("sandBox", "user", typeof(User));
The handler when we are connected
private void onconnected(object retObj, EventArgs ard) { string a = ""; // Create the User-object User user = new User(); user.firstname = "Peter"; user.lastname = "Kaptein"; user.userID="1"; // We need this to connect the specific object // to the sandbox user.sandBoxName = "sandBox"; // Set the remote object ID for shared objects user.setRemoteObjectID(); // Send the update string result; result=user.updateRemoteObjects();
What happens here?
- Registering the Class “User” – Both clients register the class “User” to a specific handler “user” and a specific SandBox “sandBox”.
- Waiting for the SandBox connection – Both clients wait for the SandBox to be connected before taking any action
- Creating a new “User” object – One of the clients create a new User object
- Setting the Remote Object ID – As we can share multiple objects from multiple sandboxes, we need a unique ID for that one sandbox.
- Setting the SandBox – As the User object can exist in multiple sandboxes, we define per “User” object in which SandBox it will live and to which sandbox it will be registered when created.
- Updating the Remote objects – By calling updateRemoteObjects, we send the update – in this case an entire new object – to all Clients who also registered the User Class to sandbox “sandBox” using the hander “user”.
Sandboxes are auto-detected
Every time you try to connect to a SandBox, the Framework performs a scan of the IP range in which your computer lives and your application runs.
If a Server is detected, it will be pinged for an IP-address related to the SandBox we want to use.
Last, the Client will connect to the IP-address as provided by the Server.
Posted on June 13, 2011
0