Reload desktop app from new IP address

Develop and Deploy Native Apps for Windows, OS X, Linux, Unix ...

Reload desktop app from new IP address

Postby joedarock » Thu Nov 03, 2016 6:49 pm

I want to deploy my industrial instrumentation app, which was developed as a web app, so that it runs as a desktop app. The web app loads from an embedded server into the browser, connects to a websocket at the embedded server address and then continuously retrieves data that gets displayed on the browser's CrossUI gui. When the user enters a new server address in the browser's address window, the web app restarts and reloads all new data. That works fine.

Now I want to deploy the app as a desktop application. In this case, it must be able to start, connect to a websocket on a user-defined server, disconnect from the websocket on the present server and then reconnect to a new user-defined server and re-display all new data.

How do I reset the desktop app and all its variables so it connects to the new server and displays new data, all without losing the user-specified new server address?
joedarock
 
Posts: 161
Joined: Thu Nov 19, 2015 8:39 pm

Re: Reload desktop app from new IP address

Postby support » Fri Nov 04, 2016 2:42 am

1. Keep all widgets' init status, reset them before changing 'server address'

2.add your 'server address' in the url hash, and get the 'server address' after the page was reload

javascript code
// set the new server to location.hash, and reload the page
xui.History.setCallback(function(str){
location.reload(true);
});
xui.History.setFI('newServer');


javascript code
//get the server from location.hash
var currentServer = decodeURIComponent(location.hash).replace(/^#!/,'');


3. Try to refresh the root widgets, for example,

   
Class('App', 'xui.Module',{
Instance:{
iniComponents : function(){
// [[Code created by CrossUI RAD Studio
var host=this, children=[], append=function(child){children.push(child.get(0));};

append(
xui.create("xui.UI.Block")
.setHost(host,"xui_ui_block1")
.setLeft(120)
.setTop(100)
.setWidth(460)
.setHeight(310)
);

host.xui_ui_block1.append(
xui.create("xui.UI.ComboInput")
.setHost(host,"xui_ui_comboinput2")
.setLeft(70)
.setTop(60)
.setWidth(220)
.setLabelSize(100)
.setType("input")
.setLabelCaption("UI")
.setValue("a")
);

append(
xui.create("xui.UI.ComboInput")
.setHost(host,"xui_ui_comboinput6")
.setLeft(200)
.setTop(50)
.setWidth(220)
.setLabelSize(100)
.setLabelCaption("Data Source")
.setType("listbox")
.setItems([{
"id" : "a",
"caption" : "ds 1",
"image" : "{xui.ini.img_icon}"
},
{
"id" : "b",
"caption" : "ds 2",
"image" : "{xui.ini.img_icon}"
},
{
"id" : "c",
"caption" : "ds 3",
"image" : "{xui.ini.img_icon}"
},
{
"id" : "d",
"caption" : "ds 4",
"image" : "{xui.ini.img_icon}",
"disabled" : true
}])
.setValue("a")
.onChange("_xui_ui_comboinput6_onchange")
);

return children;
// ]]Code created by CrossUI RAD Studio
},
_xui_ui_comboinput6_onchange:function (profile,oldValue,newValue,force,tag){
var ns = this, uictrl = profile.boxing();
ns.xui_ui_comboinput2.setValue(newValue);
ns.xui_ui_block1.refresh();
}
}
});
   
support
 
Posts: 350
Joined: Sat Apr 27, 2013 9:22 am


Return to CrossUI for Desktop Apps

Who is online

Users browsing this forum: No registered users and 0 guests

cron