Update: First round trip test successful

Posted on June 13, 2011

0


What is it all about? – Remote objects and sandboxes

HotForestGreen takes two base concepts into the design:

  1. Remote Objects – Which can be shared over an Application Cluster and can update each other when data changes.
  2. 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:

  1. The Test Server/Client – Which starts a HotForestGreen Server and initiates a SandBox
  2. 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?

  1. Initiating the Server – Making sure we can connect to something
  2. Initiating a SandBox – Allowing us to share objects
  3. Responding to the “SandBox Found” callback – On the Test Client and immediately:
    1. Creating a Remote Object – For testing purposes
    2. Sending a Remote Object Data Update – To all the other clients connected to that SandBox
  4. Receiving the Remote Object Data Update – On the Test Server/Client
  5. 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.

When you update a Remote Object somewhere in your Application Cluster, all instances of that Remote Object anywhere else will automatically be updated as well, provided that:
  1. 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
  2. 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:

  1. Remote Mouse / Remote Keyboard – Using another computer or a tablet you can manipulate the mouse and keyboard on the Remote computer
  2. 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
  3. 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));
The responder when connected
private void onconnected(object retObj, EventArgs ard)
{
 // Nothing for now
}
The Client
// 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?

  1. Registering the Class “User” – Both clients register the class “User” to a specific handler “user” and a specific SandBox “sandBox”.
  2. Waiting for the SandBox connection – Both clients wait for the SandBox to be connected before taking any action
  3. Creating a new “User” object – One of the clients create a new User object
    1. Setting the Remote Object ID – As we can share multiple objects from multiple sandboxes, we need a unique ID for that one sandbox.
    2. 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.
    3. 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.

 

Advertisements
Posted in: update