PureMVC
Home
About
Code
Docs
FAQ
Forums
News
Showcase
Contact
Jobs
Welcome,
Guest
. Please
login
or
register
.
May 19, 2013, 07:46:42 PM
News:
ATTENTION: Spambots must die! Humans must visit
http://contact.futurescale.com
to request forum access.
PureMVC Architects Lounge
PureMVC Manifold
Port to AS3
Standard Version
Remote Objects
Pages: [
1
]
« previous
next »
Author
Topic: Remote Objects (Read 8024 times)
giuly19
Newbie
Posts: 7
Remote Objects
«
on:
January 30, 2009, 05:15:38 AM »
Is it ok to have all the remote objects declared static in a separate class instead of declaring them into the proxies? I thought of this because I might need at some point to access the same remote object in different proxies. Thanks!
Logged
Jason MacDonald
Sr. Member
Posts: 243
Re: Remote Objects
«
Reply #1 on:
January 30, 2009, 06:59:34 AM »
Sounds like a use case for a delegate class which multiple proxies can utilize. I know there's a few threads around regarding this. Try a search for "delegate".
Logged
giuly19
Newbie
Posts: 7
Re: Remote Objects
«
Reply #2 on:
February 02, 2009, 04:20:58 AM »
ok. so I have a delegate class now, in which I've declared all of my remote objects. I register it at startup, and retrieve it in every mediator I need data. Is it ok to do that or do I have to register proxies that will call my Delegate Class. thanks
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Remote Objects
«
Reply #3 on:
February 02, 2009, 07:04:35 AM »
You don't want this delegate in your mediators. Instead call them from your proxies and send notifications to the mediators when data is loaded.
-=Cliff>
Logged
giuly19
Newbie
Posts: 7
Re: Remote Objects
«
Reply #4 on:
February 03, 2009, 06:32:41 AM »
Ok. The Delegate Class I used is a Proxy. How do the proxies, that need the data to send it to mediators, know when the data arrives into the Delegate Class from .Net (because they can't listen to Notifications) ? Using a Command for each proxy results in a big number of commands. Let me know if I should use another approach. Thanks!
Logged
Joel Hooks
Courseware Beta
Sr. Member
Posts: 146
baby steps
Re: Remote Objects
«
Reply #5 on:
February 03, 2009, 10:42:25 AM »
Quote from: giuly19 on February 03, 2009, 06:32:41 AM
Ok. The Delegate Class I used is a Proxy. How do the proxies, that need the data to send it to mediators, know when the data arrives into the Delegate Class from .Net (because they can't listen to Notifications) ? Using a Command for each proxy results in a big number of commands. Let me know if I should use another approach. Thanks!
I generally make my delegates static classes that are referenced in my interested proxies or run a single command with a switch/case that pushes the data to the appropriate proxies based on the information received.
Logged
http://joelhooks.com
- my ramblings about developing with actionscript and python using pureMVC and django respectively.
giuly19
Newbie
Posts: 7
Re: Remote Objects
«
Reply #6 on:
February 04, 2009, 08:26:22 AM »
Is it ok like this ? :
From view, an event is dispatched to retrieve data, it is caught by a listener defined in mediator, which calls a proxy, which finally will call the Delegate Class in which I have all my remote objects. When data is received from .Net, Delegate Class will send a notification , which is caught by the mediator. Or should I use a Command that, with switch/case depending on the type of the notification, will send a different notification (finally will be caught by a mediator) with the data in body ?
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Remote Objects
«
Reply #7 on:
February 04, 2009, 10:02:51 AM »
The delegate class should return the data to the proxy, which manages access to that data for the rest of the app. Then the proxy sends a notification that the mediator is interested in. It can send the data along in the body of the note or the mediator can retrieve the proxy and get the data when it receives the note.
-=Cliff>
Logged
giuly19
Newbie
Posts: 7
Re: Remote Objects
«
Reply #8 on:
February 05, 2009, 01:21:40 AM »
Quote from: puremvc on February 04, 2009, 10:02:51 AM
The delegate class should return the data to the proxy,
which manages access to that data for the rest of the app. Then the proxy sends a notification that the mediator is interested in. It can send the data along in the body of the note or the mediator can retrieve the proxy and get the data when it receives the note.
-=Cliff>
This is what I want to ask you. How do I return data from delegate class to proxy (which is a proxy to proxy communication) so that the proxy to know when to send the notification to the mediator ?
«
Last Edit: February 05, 2009, 01:24:41 AM by giuly19
»
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Remote Objects
«
Reply #9 on:
February 05, 2009, 06:27:37 AM »
Make the proxy implement IResponder and have the Proxy pass itself to the delegate with the call. The delegate should set the Proxy as the responder for the call, not itself. So the response comes directly back to the Proxy not the delegate.
-=Cliff>
Logged
giuly19
Newbie
Posts: 7
Re: Remote Objects
«
Reply #10 on:
February 05, 2009, 12:40:10 PM »
Quote from: puremvc on February 05, 2009, 06:27:37 AM
Make the proxy implement IResponder and have the Proxy pass itself to the delegate with the call. The delegate should set the Proxy as the responder for the call, not itself. So the response comes directly back to the Proxy not the delegate.
-=Cliff>
public class Delegate{
private var responder:IResponder;
private ro:RemoteObject;
public function Delegate(responder:IResponder)
{
this.responder = responder;
ro = new RemoteObject("fluorine");
ro.source = "NameSpace.ClassLibrary";
}
public function getData():void
{
var token:AsyncToken = ro.DotNetFunction();
token.addResponder(responder);
}
}
public class MyProxy extends Proxy implements IProxy,IResponder
{
...
public function callDelegate():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData();
}
public function result( rpcEvent : Object ) : void
{
data = rpcEvent.result;
}
public function fault( rpcEvent : Object ) : void
{
data = new Object();
}
}
Is it ok like that ? It's similar with CafeTownsend but I am using a remote object with source to .NET to get data, instead of a HttpService from an XML file.
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Remote Objects
«
Reply #11 on:
February 06, 2009, 06:23:51 AM »
That's it.
-=Cliff>
Logged
newtriks
Courseware Beta
Full Member
Posts: 23
Re: Remote Objects
«
Reply #12 on:
February 08, 2009, 07:57:00 AM »
Here is an example of this exact scenario, ensure you check the Manifold as a lot of the queries made are uploaded already there answering your question.
http://trac.puremvc.org/Demo_AS3_Flex_CF_QueryCFC
Logged
giuly19
Newbie
Posts: 7
Re: Remote Objects
«
Reply #13 on:
February 26, 2009, 03:10:36 AM »
One more question:
Lets say that in MyProxy I have 2 functions that call different methods from Delegate:
public function callDelegate1():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData1();
}
public function callDelegate2():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData2();
}
public function result( rpcEvent : Object ) : void
{
data = rpcEvent.result;
}
public function fault( rpcEvent : Object ) : void
{
data = new Object();
}
The Delegate class notifies MyProxy when data is retrieved. The result function is called. If different type of results are expected it's ok, I've resolved that by checking the rpcEvent.result type (one ArrayCollection and the other XML). Now comes the question:
If both functions from delegate class retrieve the same type of data ? How do I handle this ? I thought of something old school like having a property in MyProxy that is set to a specific value when a function is called from Delegate:
private var typeOfResult:String = "";
public function callDelegate1():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData1();
typeOfResult = "getData1";
}
public function callDelegate2():void
{
var delegate : Delegate =new Delegate( this );
delegate.getData2();
typeOfResult = "getData2";
}
public function result( rpcEvent : Object ) : void
{
switch(typeOfResult){
case "getData1": ....
case "getData2": ....
}
}
If there is another approach let me know. thanks
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: Remote Objects
«
Reply #14 on:
February 26, 2009, 09:19:10 AM »
Research the use of the AsyncToken returned from service calls in Flex. Have the delegate return the token to the proxy when it makes the call. Have the proxy set dynamic properties on the token that give a clue about the context in which the call was made.
Later, the ResultEvent will have a token property with your values that were set on it so you can figure out what you're supposed to do with the result data.
-=Cliff>
Logged
Pages: [
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Announcements and General Discussion
-----------------------------
=> General Discussion
=> Getting Started
=> Architecture
=> Public Demos, Tools and Applications
===> Fabrication
-----------------------------
PureMVC Manifold
-----------------------------
=> Port Authority
===> Contributor Central
===> Client Side
===> Server Side
=> Port to AS2
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to AS3
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to ColdFusion
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to C++
===> MultiCore Version
=====> Demos and Utils
=====> Bug Report
=> Port to CSharp
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to Dart
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Haxe
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Java
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to JavaScript
===> Demos and Utils
===> Native JS Branch
=====> Bug Report
===> PrototypeJS Branch
=====> Bug Report
===> Objs Branch
=====> Bug Report
===> MooTools Branch
=====> Bug Report
===> ExtJS Branch
=====> Bug Report
=> Port to Objective C
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to Perl
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to PHP
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Python
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Ruby
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to TypeScript
===> Standard Version
=====> Bug Report
=====> Demos and Utilities
===> MultiCore Version
=====> Bug Report
=====> Demos and Utilities
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Powered by SMF 1.1.11
|
SMF © 2006-2007, Simple Machines LLC
Loading...
Copyright © 2006-2008 Futurescale, Inc.