Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Proxy to Controllers/Proxy?  (Read 7199 times)
darnpunk
Newbie
*
Posts: 5


View Profile Email
« on: January 30, 2009, 07:16:10 »

Is it acceptable to send notifications from the proxy that will call a controller? For instance, I have data from a remote proxy and once updated, it affects another proxy without affecting the view yet (until later on).

Let's say ServerProxy and GameStateProxy. Upon receiving an update from the ServerProxy, I need to save the latest game state to a proxy and I created GameStateProxy. From the ServerProxy, I send notifications that calls controllers to update the data.

I was thinking if I were to instead send a notification to a mediator which then sends a notification to a proxy there will be additional steps. Furthermore if there a few mediators using this proxy, which mediator should handle this responsibility? This is why I find that proxy to controller is the easiest way. Is this right?

Is there a rule of thumb on how many proxies one should have in an application (e.g. game) like session proxy, remote proxy, list of character movieclips proxies etc? Should they be compacted into one? How do you handle proxy to proxy communications?

Regards,
darnpunk
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #1 on: January 30, 2009, 08:58:13 »

How do you handle proxy to proxy communications?

I consider my data model to be entwined with itself, meaning I handle proxy-to-proxy communications directly. I have no problems calling an instance of another proxy in my applications data model from any other proxy in the same model.

In terms of how many proxies an application might need... well, that depends on the granularity you want/need to achieve for your purposes. There is no set limit outside of the obvious limit placed on the platform and system resources. For some portions of my model I will store a collection of objects in an ObjectListProxy, with all of the VOs proxied there and only there. Other times, I want a finer grain to my control so I will create the ObjectListProxy as well as creating individual ObjectProxy objects for each of my unique Objects.

You don't need to have a command between your proxy communications, but you certainly can. It is perfectly acceptable to initialize and activate a command from within a Proxy.
« Last Edit: January 30, 2009, 10:49:03 by Joel Hooks » Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
darnpunk
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: January 31, 2009, 07:05:34 »

Thanks for the feedback Joel. Definitely helpful for my case.

I read in one of the threads that adding Commands might add complexity. I am trying to avoid using commands/controllers as much as possible. Unless the commands are reusable or have more than a few lines of codes, I manipulate the data through my mediators.

For example:

  • I receive a game state update (e.g a new user enters room) from the server.
  • ServerProxy sends notification to command or updates GameStateProxy directly.
  • GameStateProxy then sends a notification to mediators of this update.
  • An interested AnimationMediator would probably show an animation of a user entering a room (e.g door open) and sends a notification once animation is completed.
  • A StageMediator upon receiving the notification from AnimationMediator will then grab the required data (e.g. user appearance data) from the GameStateProxy and adds a new character to the stage.

The above sequence is receive update, save updated data and update the screen (being animation first then show new character). Am I doing it right?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: January 31, 2009, 07:40:14 »

Bada-bing. Perfect.

-=Cliff> 
Logged
Pages: [1]
Print