Server API

Server API makes it easy to develop highly scalable client side applications using Teleiotes. It is one of the most important improvements from the version 2.0. With server API, you can create and store variables that are assigned by the server. They represent some values from the server. There are two types of these variables:

Server Connectors

These variables connect to the server only when they are connected or when they are manually updated. In other words, they contain the values since the last updating of the variable. They are ideal to use when the data from server is less likely to change in near future e.g. Map data.

 

var server = new Server();

server.add({
                name: "myvar",
                link: "Code.aspx?code=1",
                defaultval: null,
                autoupdate: false
            });

 

Server Observers

As the name indicates, these variables keep on observing the server location for any change in the information. When any changes are detected, they are replicated to the value of the observer. These variables are more reliable for the data that is likely to change in near future e.g. user notifications.

 

var server = new Server();

server.add({
                name: "myvar",
                link: "Code.aspx?code=1",
                defaultval: null,
                autoupdate: true
            });

 

By default, the auto update time is set to 5000ms. You can change it by

 

ServerOptions.autoupdatein = 10000;

Please note that setting this value too small or creating many observers might affect the performance of your application.

You can lookup a previously set variable simply by calling the lookup function.

 

var d = server.lookup('myvar');

Last edited Dec 26, 2011 at 5:49 PM by mihsathe, version 3

Comments

No comments yet.