Well, just off the top of my head, you could use the jQuery AJAX call to send a request to the app and handle that in HandleURL. Just for a simple test…
I added a constant called kSendData to the default page with the following content:
var dataObject = {
session:"#sessionID#",
values:"#values#"
}
$.ajax({
method: "POST",
url: "/dataReturn",
data: JSON.stringify(dataObject)
});
I then added a button to the default page with this as its Pressed event:
Sub Pressed() Handles Pressed
var r as new Random
self.ExecuteJavaScript( kSendData.ReplaceAll( "#sessionID#", Session.Identifier ).ReplaceAll( "#values#", r.InRange( 100, 200 ).ToString ) )
End Sub
Added a property to the Session object, which I then made computed and added a break in the Setter:
Public Property currentValue as Integer
And, finally, in App.HandleURL:
if Request.path = "dataReturn" then
var jsonResponse as new JSONItem( Request.Body )
if jsonResponse.HasName( "session" ) and jsonResponse.HasName( "values" ) then
var theSession as WebSession = app.SessionWithIdentifier( jsonResponse.Value( "session" ).StringValue )
if theSession <> nil then
Session( theSession ).currentValue = jsonResponse.Value( "values" ).IntegerValue
Response.Status = 200
end if
end if
end if
Running this project, when I click on the button the data is sent to the App via an HTTP request. In the HandleURL event I check for the path, validate the data, find the Session, and set the currentValue property’s value.
There are a number of ways this could be done, that’s just one I cooked up in about five minutes.