NonDesktop apps

Posted: 2017-01-20 in NonDesktop

Web and Mobile Apps are stateless.
What this means is that you cannot guarantee a persistent connection between the Web client and the server.

When requests are made by the browser these arrive on the server and are handled by worker processes based on their availability. Lianja uses connection pooling to optimize performance.
Not only does it use connection pooling for web requests it also uses ODBC connection pooling to handle Virtual Table access.

Therefore, executing a command only affects the server process that the command runs on. It has no effect on the client and the next Lianja.execute() may run in a completely different server context.

In Lianja v2.0 we have made it dramatically easier to share data in real time between multiple Lianja processes running in parallel.

In HTML5 Web/Mobile there is the concept of “localStorage” and “sessionStorage”.

In the Lianja v2.0 Desktop client “sessionStorage” is non persistent data that can be shared across multiple concurrent processes e.g. background processes gathering data from instruments or multiple Lianja windows on the desktop.

Access to data in sessionStorage is handled automatically for you so that concurrent reads, updates and removing of data items is atomic.

You access sessionstorage from the Lianja system object Lianja.sessionStorage.


// The number of key/value pairs in sessionStorage


// These should be quite explanatory
Lianja.sessionStorage.setItem(key, value)
value = Lianja.sessionStorage.getItem(key)

Lianja uses a shared memory segment to maintain sessionStorage.

Lianja will automatically keep the keys and their values consistent between each running process as you reference the items stored in SessionStorage. If you want to keep complex objects as the values for keys then use json_encode() and json_decode() to handle serialization and deserialization of the objects.

// in the main process App
private myobj = object("name" => "Barry", "company" => "Lianja")
Lianja.setItem("myobj", json_encode(myobj) )
// then in another process that needs to read objects from the main App window
private myobj = json_decode( Lianja.sessionStorage.getItem("myobj") )

Note that each time you call any of the methods or reference the length property the shared sessionStorage will be automatically kept current for you.

there is a “Session data changed” delegate and a “Session data changed interval” in App Settings.

Lianja will check for changes in the sessionStorage every #msecs and call the “Section data changed” if any changes in the sessionStorage have been made.
This is fast as a transaction sequence number is kept as part of the sessionStorage so no deserialization of data is required.
There is also a property called “datachanged” and “datachangedinterval” (in milliseconds) so this can be used by non GUI applications (background worker processes etc).

In Lianja v2.0 you also have several new classes that handle custom shared memory access and custom system semaphores.
New “SharedMemory” system class

m_shareddata = createObject("sharedmemory")

// attach will create the shared memory if it does not exist. Args are the "key" and the "size"
m_shareddata.attach("com.lianja.myshareddata", 64*1024)

// set key/value pairs
m_shareddata.setItem("mykey", somevalue)

// get value
m_value = m_shareddata.getItem("mykey")

New “SystemSemaphore” system class

m_sem = createObject("SystemSemaphore")

// setKey will create the SystemSemahore if it does not exist. 

// acquire exclusive access to a resource across multiple running processes

// do something...

// release access to the resource 

Up until now, I have only created desktop apps. I am now planning on making my apps available for the web.
My current apps use VFP/Recital code.
I am also not used to programming for a client / server design.
I have read that you use javascript on the client and Lianja/VFP on the server side when you want to call server side procedures.
Here are just some of the questions I have.
1. When do you use rsp (Visual FoxPro Server) pages?
2. When do you use jssp (JavaScript Server) pages?
3. What and when is jquery, json or odata used?
4. How and why would you use each of these?

Lianja is a complete Apps platform.
It is not just an IDE nor is it just a language.
You build Apps visually using “best practices“.

Apps are built out of pages and pages consist of sections etc.
You can build Web and Mobile Apps just as you can build desktop apps if you follow best practices. “Think NoCode“.
There are many pre-built sections that have a lot of built-in functionality. “Think Login page -> App Center -> Apps -> Pages -> UI Navigation“.

The Lianja HTML5/JavaScript Client for an Web/Mobile App is generated for you. It incorporates the LianjaWebFramework which manages all of the UI layout management, App and page navigation, data navigation, and all CRUD (Create Read Update Delete) operations on the sections (Forms, Grids etc) assembled into an App. You do not need to write any server side data access code. None.

The LianjaWebFramework is an HTML5/JavaScript library that takes care of the heavy lifting and handles automatic and transparent data binding between the client App running in the browser and your data which is on a remote server under the control of the Lianja Cloud Server.

The LianjaWebFramework was developed by ourselves in JavaScript and it uses jQuery, jQuery Mobile, Twitter Bootstrap and a variety of other JavaScript components some of which are commercial and some of which are open source licensed (Apache 2, BSD, LGPL).

There are occasions where you may want to build a custom UI that incorporates other UI widgets that you like.
You do this by building a WebViewWidget which is loaded into a WebView. The HTML5/JavaScript for the WebViewWidget can be dynamically generated by an .rsp page (Server side Lianja/VFP) or a .jssp page (Server side JavaScript). Both Lianja/VFP pages and JavaScript pages are part of the Lianja Cloud Server. (PHP will be included in this too very soon).

To answer your questions.
1. Do you know Lianja/VFP? Then write your dynamic HTML5/JavaScript code in that data centric language.
2. Do you know JavaScript? Then write your dynamic HTML5/JavaScript code in JavaScript.
3. You don’t need to know unless you are building custom WebViews.
4. See above.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s