Re: Mobile offline programming


Lawrence Fisher
 

I understood that you were having fun...

The way it works, is:

Main Program
Login (Rich client non-interactive) called by the execution.properties
       Calls Enter login (Regular rich client) subtask
       If all OK, calls Menu (Offline rich client) 

menu waits for someone to tap.

When someone taps, Menu then raises an event (Sync from Server) in the Main Program

That is when I get -197. From what you are implying, the problem is Login?

 
Regards

Lawrence
Author of the award winning book, "Kill Me Now!", amusing stories from the world of dating



From: Todd Baremore <tbaremor@...>
To: main@magicu-l.groups.io
Sent: Thursday, March 30, 2017 3:33 PM
Subject: Re: [magicu-l] Mobile offline programming

Lawrence,

I understood the book reference. Just having a bit of fun with it. No offense intended.

In my app, the online tasks are batch tasks for updating data in either direction.  All my interactive tasks are offline.   If an online task is open when the timeout occurs, I do not think you will be able to reconnect.  All my online batch tasks are launched by raising an events that are handled in the main program.

To get a better of idea of what is happening try the following:
In your startup program evaluate ClientSessionSet('EnableCommunicationDialogs','FALSE'LOG).   This will turn off the error messages.

In the Main program create an event handler for Internal Event "Unavailable Server" and set the scope to SubTree. In the handler put the following   :
Verify Warning expression = 'Unable to establish a server connection. Status code : '&Str(ServerLastAccessStatus(),'1')

Launch your app , wait for the timeout and then call a program that accesses the server.

If the returned code is 4 then –> The context is no longer available (such as due to ContextActivityTimeout) and the client could not recreate a new context in the Magic xpa server since there were non-Offline tasks in the execution call tree.

You can also check the BrokerActivity.log for more info on what is happening.

Todd

On 3/30/2017 2:58 AM, Lawrence Fisher via Groups.Io wrote:
Kill Me Now is the name of my book (http://killmenow.org)

I am doing something wrong then and I cannot figure out what. The Help and the other documentation are not helpful and neither is support
 
Regards

Lawrence
Author of the award winning book, "Kill Me Now!", amusing stories from the world of dating



From: Todd Baremore <tbaremor@...>
To: main@magicu-l.groups.io
Sent: Wednesday, March 29, 2017 9:15 PM
Subject: Re: [magicu-l] Mobile offline programming

Lawrence,
It is working for me. I have single user RIA runtime license for XPA 3.2.   Using two tablets, I am able to push data to the server from both tablets without having to restart the Android app, provided I wait 30 seconds (see below).  If I try to do both at the same time, one of them gets an error which is to be expected.
In my magic.ini I have  ContextInactivityTimeout=300  (30 seconds)
from my mgrb.ini :
[APPLICATIONS_LIST]
My_App = MgxpaRuntime.exe /INI=\\server1\folder1\control\Magic_XPA3_RIA.ini,,,,0,1
Now please step down from the ledge or drop the gun/any other applicable object.
Todd

On 3/29/2017 11:11 AM, Lawrence Fisher via Groups.Io wrote:
I have had no success at all

Kill me now
 
Regards

Lawrence
Author of the award winning book, "Kill Me Now!", amusing stories from the world of dating



From: Todd Baremore <tbaremor@...>
To: main@magicu-l.groups.io
Sent: Tuesday, March 28, 2017 4:39 PM
Subject: Re: [magicu-l] Mobile offline programming

Lawrence,
What happens if you restart the broker after the context timeout?
I'll be visiting a customer tomorrow to test my upgrades.  I'll let you know if I have any success.
Todd


On 3/28/2017 8:49 AM, Lawrence Fisher via Groups.Io wrote:
It is "available" 

This is a regular runtime license

Regards

Lawrence
Author of the award winning book, "Kill Me Now!", amusing stories from the world of dating



From: Todd Baremore <tbaremor@...>
To: main@magicu-l.groups.io
Sent: Tuesday, March 28, 2017 2:34 PM
Subject: Re: [magicu-l] Mobile offline programming

Lawrence,
In the broker monitor, what is Server Application Status after the context has timed out?
Todd

On 3/28/2017 2:19 AM, Lawrence Fisher via Groups.Io wrote:
For me that does not work.

My context does timeout but when I try the sync to server, I get the -197 which is context not found. This is 3.2a

I even tried doing this:

Updated a Main Program logical variable, "Must Sync" with TRUE
Then I have a Main Program timer event that runs every 5 minutes and if the "Must Sync" is true, runs the sync to server. -197.

What am I doing wrong?
 
Regards

Lawrence
Author of the award winning book, "Kill Me Now!", amusing stories from the world of dating



From: Todd Baremore <tbaremor@...>
To: main@magicu-l.groups.io
Sent: Tuesday, March 28, 2017 2:48 AM
Subject: Re: [magicu-l] Mobile offline programming

Tim,

I'm experimenting with setting Context Inactivity Timeout in lieu of deleting a context.  I don't have a runtime license available, so I'm experimenting with Studio.  Setting the timeout to 600 ( 1 minute ) does indeed delete the inactive context, but does not allow any new contexts to be created.  I did notice that Server Application Status switches from "Available" to "Studio Mode" after the context times out.  On a customer server without any open contexts  the Server Application Status remains "Available".   I'll visit this customer later this week to run some tests.

Todd

On 3/27/2017 5:37 PM, Tim Downie wrote:
Ive had inconsistent results with this and this was due to a bug if using https which was fixed in3.1b. The only thing is you can never kill this context from the app - or at least i cant but i think this is logical as in a program can not terminate its own context.

Id like to try this process in 3.2 but havnt had the time yet. I will be back to this soon as we have another client wanting mobile


From: main@magicu-l.groups.io <main@magicu-l.groups.io> on behalf of Todd Baremore <tbaremor@...>
Sent: Monday, 27 March 2017 5:28:42 PM
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Mobile offline programming
 
Tim and Lawrence,

After some guidance from MSE and pulling my foot out of my mouth, I need to make some corrections.

First, only offline programs are copied to the mobile device. This only happens when the app is started.
Second, you can open a new context by calling a non-offline program. Here is my mistake:
The ServerLastAccessStatus() does not check if the server is available. It returns the status of the LAST request, which could have been an hour ago.

To test this I started my mobile app with a connection to the server.  With my mobile app still running, I shutdown the server(s)/broker and restarted the broker.   >From the mobile app I then tried to push data to the server, which was successful.    I still need to work out server error handling, but this is great news for mobile offline development.   Anyone up for a Go-To-Meeting to put our heads together on this (and share the pain?) I'm thinking Thursday afternoon New York time.

Todd


On 3/26/2017 10:11 PM, Todd Baremore wrote:
TIm,

I agree.  Ideally a server will have a floating pool of mobile contexts.  This would allow a customer to to put your app on 20 devices while only purchasing a 5 user licenses.   At startup each device would synch the source xml files, launch your app (which would check for any data synchronization) and then drop the context if applicable for the app to do so.  For server dependent apps the device would stay connected to the server and the licensing scheme would be 1:1.  For mobile offline apps, having an N:1 licensing scheme will give us a much more affordable solution to offer our customers.  

If a mobile app is started without a server connection and the application ecf has been updated on the server you could have problems with:
DataviewToDataSource() if column names have changed
Callling server programs if the number of parameters or their data types have changed

In order for this diabolical plan to work, the developer would be responsible for determining a version difference between the server and mobile app (we can already do this) and maintaining some form of change list that could be checked after the mobile app creates a new context.  The mobile app would then need to determine if it is safe to synchronize data or call a server program.   I'm doubtful that updating the app xml files will ever be achieved with the app open and program(s) running.

I'm sure there is more to it than I have outlined here. If MSE is listening I would like to hear your thoughts on the matter.

Todd



On 3/26/2017 7:14 PM, Tim Downie wrote:
This is where in my belief magic mobile is flawed....you should be able to open a connection (context ) when you like and then immediately terminate it, and then create another one if/when you need to interact with the server - this  reduces connections to the server etc.

if you start without a context it will then create one, but it should also be able to create a new context if for some reason the context is not found.





From: main@magicu-l.groups.io <main@magicu-l.groups.io> on behalf of Todd Baremore <tbaremor@...>
Sent: Sunday, 26 March 2017 3:04 PM
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Mobile offline programming
 
Lawrence,
This is my understanding and experience of how contexts works.  If anyone knows better please correct me as needed.
A context is added to the server upon startup of your mobile device application, assuming your device has network access to the server.  With the Context Inactivity Timeout set to 2 minutes,  if your device has not made any requests of the server in 2 minutes, the context is closed and your app is now offline.   The only way to reestablish a context is to close and restart the app.  The default Context Inactivity Timeout is 24 hours which means you could start your app in Seattle in the morning, catch a flight to New York and still have the same context available when you land in New York as long as you leave the app running.
Open the broker monitor on your server before starting your mobile app.  You will see the traffic coming from you mobile device and the creation of a context for your device.  The first time you run your app, the source xml is sent to the device which is why it takes a bit longer to start the first time.
Assuming the Context Inactivity Timeout is set to 24 hours, if you want to test what happens to your app when it loses the connection to the server, start your mobile app, turn off the mobile/WiFi data connections on your device.  Work with your app for a few minutes and then turn on your mobile/WiFi connections on and try to send data to the server. In the Broker Monitor you will notice that the context is maintained even though the device has lost its network connections.
This could prove helpful in your next book, "Kill Me Again", amusing anecdotes from the world of Magic mobile development
Todd

On 3/26/2017 8:51 AM, Lawrence Fisher via Groups.Io wrote:
Hi all

I am tried to define a proof of concept working with offline mobile.

I defined a Context Timeout of 2 mins.

I managed to get the sync from server to client working with no problem. Once there is the timeout, the client continues to work.
The problem is when I need to update the server, meaning "client to server"

From what I understand from the documentation, when you make the first server access, such as accessing a server table, there is a connection to the server. What I get is an error -197 which is context not found.

What am I doing wrong?


 
Regards

Lawrence
Author of the award winning book, "Kill Me Now!", amusing stories from the world of dating


















Join main@magicu-l.groups.io to automatically receive all group messages.