Reset Tide remoteObject for AIR applications

85 views
Skip to first unread message

Treur

unread,
Aug 17, 2011, 5:47:32 AM8/17/11
to gran...@googlegroups.com
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.

wdrai

unread,
Aug 24, 2011, 6:41:48 AM8/24/11
to gran...@googlegroups.com
Interesting. Can you post a JIRA and/or a git pull request with your patch ?
It would probably be better if the Tide object was a listener for the properties of the service initializer and reinits all managed RemoteObjects when one of the properties changes but it would be a bigger change.


Treur

unread,
Aug 26, 2011, 10:47:37 AM8/26/11
to gran...@googlegroups.com
I've created an Issue: http://www.graniteds.org/jira/browse/GDS-913

I wouldn't mind to implement your suggestion in my local patch an send a pull request, but it would take some time because I'm not that familiar with Tide's inner-workings. ;)

aheydler

unread,
Dec 1, 2012, 12:43:36 AM12/1/12
to gran...@googlegroups.com
Wondering if anything ever got done with this or whether the suggested workaround is still the way to go.

I am needing this in a spring context and the user needs to be able to connect to their server of choice by entering the required IP address.

Thanks,

Andreas

wdrai

unread,
Dec 5, 2012, 10:01:03 AM12/5/12
to gran...@googlegroups.com
In fact we have planned to change the API of ServiceInitializer to something more manageable and allowing multiple servers. 
This is the ServerSession API that has been implemented for JavaFX support and will possibily be ported to Flex in 3.0 M2.
Reply all
Reply to author
Forward
0 new messages