Tonido Platform – How it Works
In case you missed it, we recently announced Tonido which is an application platform that blurs the distinction between the web and the desktop. Four applications will be part of the initial beta release, but more are coming and since it is a platform, third parties can also develop applications and deploy on top of it.
This post will try to go through some of the features of Tonido as a platform.
Tonido Core Runtime
A Tonido installation consists of a runtime referred to as the “Tonido Core” runtime and “Tonido applications”. The Tonido Core is implemented using C++ and Tonido applications are shared libraries/dlls that are loaded/unloaded dynamically.
Tonido has two primary interfaces to the outside world.
- A HTTP interface which can be accessed by a browser
- A Tonido network interface which is used to connect to other Tonido instances directly
The primary function of the Tonido platform is to abstract these two interfaces from applications and present them uniformly as a single unified interface. Let’s look at how this is organized in more detail, as shown below.
The Tonido network is a direct peer-to-peer based network, with a distributed login system. That simply means that Tonido instances will communicate with each other directly and but identity will be managed by a directory server. This directory server is called Tonido Domain Server (TDS). CodeLathe will operate one that provides Tonido identities running from the tonidoid.com domain. However, unlike many other messaging servers, the Tonido Domain Server can be run by anyone and they can provide their own identity management. So, for example, a corporation can run a Tonido Domain Server for their employees, e.g. microsoft-tonidoid.com, and Tonido instances running on any Tonido Domain Server can talk to each other.
The Tonido network functional block handles identity, connections with other Tonido instances, can transfer files and perform arbitrary data synchronization.
Utility and Other APIs
The Tonido Core runtime has other utility APIs that applications can use. They include image manipulation, notifications, activity streams.
The Core Runtime also supports managment of collection of Tonido instances called Tonido Groups. Tonido Groups can be used as a logical block for certain operations by applications. For example, Tonido Photos will send a photo folder to a Tonido Group. Tonido Workspace uses Tonido Groups to synchronize workspace items.
Other APIs include loading, suspending and managing applications; Tonido updates, patching and notifications. There are also several other minor utility APIs.
The final piece is Service management and message routing which we will talk more in detail below.
Tonido Services and Messages
This is the glue that holds the entire Tonido architecture together. The Tonido platform comprises mainly of static APIs and dynamic Services.
Static APIs are traditional APIs that can be invoked via a normal function call. These calls are synchronous, i.e. when you invoke them your code does not continue till the function call returns.
Services, on the other hand cannot be invoked directly. If you need to interact with a service, you need to send messages to it. Unlike static API’s messages are sent and processed asynchronously. i.e. your code continues to execute after sending a message. Once the service gets the message, it will perform a action and send you an optional response as another message.
Messages form the primary unit of communication within Tonido and in-between Tonido instances. For example, if you want to send a response to the browser, you will send a message to the HTTP Service. If you want to initiate a file transfer to another Tonido instance, you send a message to the File Transfer Service requesting a file transfer.
This allows Tonido applications to communicate with services in the local instance or remote Tonido instance the same way.
Just for fun, here is an example, (if you know C++), showing how easy it is to send a message to another Tonido contact.
Tonido::Data::Message::SharedPtr pMessage(new Tonido::Data::Message()); pMessage->setToPeerID(Tonido::Data::PeerID("firstname.lastname@example.org")); pMessage->setToService("TonidoPhotos"); pMessage->setOperation("Hello World!"); Tonido::Dispatcher()->postMessage(pMessage);
Tonido takes care of the rest, locating, connecting, transmitting the message to a Tonido contact “email@example.com” if he is online.
When you want to write an application, you will actually write one or more services, compile it as a shared library and it becomes a Tonido Application. Since Tonido applications are mainly written in C++, they are free to use the vast C++ libraries out there. Running in C++ also gives other advantages, performance, small size etc.
Browser Based UI
Tonido uses the browser exclusively to provide interfaces to the applications. This provides a lot of flexibility, and allows users to access their applications from anywhere. Again, there are no restrictions on the type of UIs that applications have to implement, you can use plain HTML, AJAX, Flash, SilverLight or any of the hundreds of the other web development toolkits out there. The only requirement is that the browser UI communicates with the Tonido application using HTTP(S) (GET/POST)
A fundamental part of the Tonido Platform is security. Significant amount of time has been spent on implementing secure communications, secure HTTP access and authentication methods.
Since messages are primary means for communications inside and outside Tonido, there is a authorization key that every message carries. There is a associated privilege level (message from unknown Tonido contact, message from a Tonido Group contact etc) , a source level (for example, message from the UI, message from the network), and finally a location access level (message from local machine, message from trusted machine, message from remote machine ) etc that is part of the authorization key. Message handlers in applications are free to setup restrictions on levels required for a particular operation.
Cross Platform and based on Open Frameworks
Tonido runs natively in Windows, Linux, Mac OS X and therefore can fully use the underlying OS’s capabilities if available. All four of the Tonido applications that are part of the inital release will run on all three operating systems.
Tonido does not reinvent the wheel when it comes to providing support for primitives like threading, shared pointers, image handling, storage and crypto. The Tonido platform integrates with the best-in-the-breed and permissive licensed libraries out there like boost, crypto++, sqlite and Poco to provide support. However, Tonido does not require application developers to stick to these libraries in their code, they are free to use any library out there. In fact, Tonido even provides support for applications to load and unload their own third party shared libraries.
Over the coming weeks, we will try to talk more in depth on individual parts of the Tonido design.
We are excited about Tonido and even more excited about the possibilities offered by the Tonido Platform to developers and consumers. We have only scratched the surface with the applications we have built so far and there is potential for hundreds of other applications that can do dazzling things that so far web applications and desktop applications can only dream of. And at the same time, keeping your data private and out of third party hands.
Sign up to get the Tonido Beta.