Part 1 – Frameworks
Part 2 – Directory structure
Part 3 – Application and ApplicationFacade
Part 4 – Notifications, Commands & Use Cases
Part 5 – Model & Proxy
Part 6 – The Application View & Mediator
Part 7 – The Login View & Mediator
Part 8 – The Roster View & Mediator
Part 9 – The Chat View & Mediator
Conclusion, Demo & Downloads
The model is the ‘data’ of our application and the proxy is our interface onto that data. For our particular application the model itself is basically our Jabber connection object, so the Proxy will encapsulate that and expose an interface with the following methods:
- connect(username:String, password:String, server:String):void
As you can see, the interface is very similar to our use case and commands, and this in no coincidence; each command is going to call the relevant method in its execute method.
Create a Proxy in the model folder called XMPPProxy.as using Add->New Proxy… (if you don’t see this menu item be sure you’ve installed the PureMVC FlashDevelop templates from PureMVC: First thoughts & FlashDevelop templates correctly).
I’m just going to include the Proxy code here without much explanation as it doesn’t really do anything overly complicated (all of the hard stuff has been done for us in the XIFF library 🙂 ) Have a read through the comments of each method and everything should be clear.
One thing you will notice is that the proxy dispatches another few notifications that we haven’t included in our ApplicationFacade:
So lets go back to our ApplicationFacade and add them in:
The final thing we need to do is register our new Proxy with PureMVC. We do this in StartupCommand.as using the registerProxy method:
Its quite easy to forget to do this and end up with all kinds of strange errors, so be sure to remember to register any proxies you create.
We’ve finally got the bones of our application up and running so now its on to the views and mediators!