I've recently started to use Tide and Granite for an AIR application. I want to be able to allow the user to modify the server settings during runtime, I've used the serviceInitializer component:
Ejb.getInstance().addComponentWithFactory("serviceInitializer", DefaultServiceInitializer, {
contextRoot: '/my-app',
serverName: serverNameLabel.text,
serverPort: serverPortLabel.text
});
However. If the user was already connected before (or tried to connect, but with invalid server settings), the remoteObject in Tide is already initialized. The serviceInitializer isn't used again so the old connection settings are still enabled.
I've browsed to the api of Tide and couldn't find a hook to reset the remoteObject somehow or force a reuse of the serviceInitializer. Perhaps I've overlooked it, but I did found an explicit call to initRemoteObject() in the remoteObject getter.
protected function get ro():RemoteObject {
if (_ro == null)
initRemoteObject();
return _ro;
}
I've added an extra method to nullify _ro so initRemoteObject() will be called again once I try to reconnect.
public function resetConnection():void {
if (_ro) {
_ro.disconnect();
}
_ro = null;
}
Is this the proper way to reset the connection and if so, I would propose to add a patch allowing this behavior for AIR applications using Tide. If I did overlook something and there is another way to reset the connection I would like to know so I won't have to extend Tide.