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

Show Posts

* | |

  Show Posts
Pages: 1 [2]
16  Announcements and General Discussion / Architecture / Re: Mediator with multiple views, toolbar stack ? on: November 25, 2008, 07:03:02
Each Shape property toolbar will be dispatching events to be handle by the Property Toolbar mediator (fill color, line color) which in turn sends a notification to the BoardMediator.
Board Mediator being responsible for creating the shapes on the board.

The BoardToolBar mediator only handles the tool choices: select, pen, rectangle, circle ...
The PropertyToolbar mediator will take care of the property details of the current tool (fill ...)

I am trying to use a view stack as the propertyToolbarView for now.

I dont think i need a mediator for each property toolbar.
17  Announcements and General Discussion / Architecture / Mediator with multiple views, toolbar stack ? on: November 25, 2008, 04:40:16
Hi guys,

I am facing a design problem i havent encountered before.

I have a BoardView with a boardMediator
a boardToolbarView with boardToolbarMediator, the toolbar it a tile of several Shapes.

Each Shape should be associated to a toolbar for its type (rectangle, circle, etc).

Instead of creating a RectangeToolbarMediator, CircleToolbarMediator etc ...
for each type can i create just one ShapeToolbarMediator registering several views CircleToolbarView, RectangeToolbarView etc.


Then when my boardToolMediator send a toolchange notification, ShapeToolbarMediator will listen for it and display the appropriate shapeToolbarView.

How would you do such a thing ?

-------------------
|                      H |     H: boardToolBar
|                      H |     x: shapeToolBar
|             xxx     H |
-------------------

Thanks


18  Announcements and General Discussion / General Discussion / Re: CoCoMo and PureMVC advices needed on: November 22, 2008, 12:05:44
Great !
19  Announcements and General Discussion / General Discussion / CoCoMo and PureMVC advices needed on: November 21, 2008, 03:12:24
Hi guys,

I was building a collaborative project using PureMVC, now i see that CoCoMo is knocking at the door and it will simplify a lot of work if we use it for our project.

The thing i dont know is how to integrate PureMVC with it.

Looking a this simple chat code coming from CoCoMo examples

:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:rtc="CocomoNameSpace">

<mx:Script>
<![CDATA[
import com.adobe.rtc.pods.simpleChatClasses.ChatMessageDescriptor;
import com.adobe.rtc.events.ChatEvent;
import com.adobe.rtc.pods.simpleChatClasses.SimpleChatModel;

// This simple example just shows how this shared model can be made easily bindable for MXML.
// See SimpleChatModel for details.

[Bindable]
public var chatModel:SimpleChatModel;
protected function buildModel():void
{
// Create the model: just calling the constructor won't create the collection node or pass the messages.
// Call subscribe and give it a shared ID while creating the model.
// The shared ID becomes the name of the collection node.
chatModel = new SimpleChatModel();
chatModel.sharedID = "myChat_SimpleChatModel";

chatModel.subscribe();
chatModel.addEventListener(ChatEvent.HISTORY_CHANGE, onChatMsg);
this.addEventListener(KeyboardEvent.KEY_UP, onKeyStroke);
}

protected function submitChat(str:String):void
{
var cmd:ChatMessageDescriptor = new ChatMessageDescriptor();
cmd.displayName = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID).displayName;
cmd.msg =  str;
chatModel.sendMessage(cmd);
chat_mesg_input.text = "";
}

protected function clearChat():void
{
chat_mesg_area.text = "";
chatModel.clear();
}

protected function onChatMsg(p_evt:ChatEvent):void
{
if(p_evt.message != null && p_evt.message.msg != null && p_evt.message.displayName != null)
chat_mesg_area.text += "\r\n" +  p_evt.message.displayName + ": " + p_evt.message.msg;
else
chat_mesg_area.text = "";
}

protected function onKeyStroke(p_evt:KeyboardEvent):void
{
if(p_evt.keyCode == Keyboard.ENTER) {
submitChat(chat_mesg_input.text);
}
}

]]>
</mx:Script>


<!--
You would likely use external authentication here for a deployed application;
you would certainly not hard code Adobe IDs here.
-->
<rtc:AdobeHSAuthenticator
id="auth"
userName="AdobeIDusername"
password="AdobeIDpassword"  />

<rtc:ConnectSessionContainer roomURL="YourPersonalRoomUrl" id="cSession" authenticator="{auth}" width="100%" height="100%">
<mx:Canvas width="100%" height="100%" creationComplete="buildModel()">
<mx:VBox id="chatBox">
<mx:TextArea width="800" height="500" id="chat_mesg_area"/>
<mx:TextInput width="400" id="chat_mesg_input"/>
<mx:HBox>
<mx:Button label="Submit Chat" click="submitChat(chat_mesg_input.text)"/>
<mx:Button label="Clear Chat" click="clearChat()"/>
</mx:HBox>
</mx:VBox>
</mx:Canvas>
</rtc:ConnectSessionContainer>
</mx:Application>


What would be the convertion path to a PureMVC way

Myapp.xml will sendNotification( STARTUP, app );
Which call StartupCommand

Which registers Proxies: what are my proxies here ?
ConnectSessionContainer  give access to many stuff:
    authenticator : AbstractAuthenticator
    autoLogin : Boolean = true
    fileManager : FileManager
    initialRoomSettings : RoomSettings
    isSynchronized : Boolean
    roomManager : RoomManager
    roomURL : String
    streamManager : StreamManager

What would be his place in PureMVC ?



ChatMessageDescriptor is a "simple value-object to describe chat message properties."  where should i put it ? in a descriptor folder along my models ?

cmd.displayName = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID).displayName;

chatModel will be in a ChatProxy as a VO ?

Since here the View talk to the ChatModel directly with bindable there is no mediator. Should i add one ?

Thanks for your answers i want to continue using PureMVC.  :D




20  Announcements and General Discussion / General Discussion / Re: Concept Question, proxy and vo for a chat on: October 14, 2008, 02:09:19
Thanks for these tips, i am trying hard to find the way of good coding practices.

I got the Chat app working in a pureMVC way, but before i dare to show the code here i have few questions on the architecture.

The Chat uses a connection to a FMS server, since i may extend my app with video and so on, i should separate the connection Handling form the ChatProxy.

Is a FmsConnectionService is a good way to this ? So far i did it this way:
The service is a singleton since i need only one connection, and it can send Notifications too.
(is it still a service then or should it be a proxy) ?

:
ackage org.edorado.edoboard.model.service
{
import org.puremvc.as3.interfaces.INotifier;
import org.puremvc.as3.patterns.observer.Notifier;

import flash.net.NetConnection;
import flash.events.NetStatusEvent;

    import org.edorado.edoboard.ApplicationFacade;
   
/**
* FMS connection Singleton
*
*/

public class FMSConnectionService extends Notifier implements INotifier
{
private var nc:NetConnection;

private static var instance:FMSConnectionService;

public function FMSConnectionService() {
setupConnection();
}

        /**
         * Create the required connection object and do any configuration
         */
        private function setupConnection():void {
            //A NetConnection is the pipe between Flex/Air and Flash Media Server
            nc = new NetConnection();
            //The NetStatusEvent is a dispatched status event for
            //NetConnection, NetStream, or SharedObject.
            //We want to know if the NetConnection has properly connected
            nc.addEventListener( NetStatusEvent.NET_STATUS, handlerOnNetStatus );
        }
       
        // Singleton Service
        public static function getInstance() : FMSConnectionService {
            if ( instance == null ) instance = new FMSConnectionService( );
                return instance as FMSConnectionService;
        }
       
        /**
         * Connect to the given URL
         */
         public function connect(url:String):void {
            nc.connect(url);
         }
 
         /**
         * Disconnect  the net connection
         */
         public function close():void {
            nc.close();
         }
               
        public function getNetConnection():NetConnection {
            return nc;
        }
       
       
                 /**
         *  This is the handler function of the NetStatusEvent for the NetConnection. 
         *  Here is where we can find out the connection status and send notifications 
         *  based on each result.
         */
         private function handlerOnNetStatus( event:NetStatusEvent ):void {
            var info:Object = event.info;
            trace(info.code);
            //Checking the event.info.code for the current NetConnection status string
            switch(info.code)
            {
                //code == NetConnection.Connect.Success when Netconnection has successfully
                //connected
                case "NetConnection.Connect.Success":
                    sendNotification(ApplicationFacade.CONNECT_SUCCESS, info.code);
                    break;
               
                //code == NetConnection.Connect.Rejected when Netconnection did
                //not have permission to access the application.   
                case "NetConnection.Connect.Rejected":
                    sendNotification(ApplicationFacade.CONNECT_REJECTED, info.code);
                    break;
               
                //code == NetConnection.Connect.Failed when Netconnection has failed to connect
                //either because your network connection is down or the server address doesn't exist.   
                case "NetConnection.Connect.Failed":
                    sendNotification(ApplicationFacade.CONNECT_FAILED, info.code);
                    break;
               
                //code == NetConnection.Connect.Closed when Netconnection has been closed successfully.         
                case "NetConnection.Connect.Closed":
                    sendNotification(ApplicationFacade.CONNECT_CLOSED, info.code);
                    break;
            }
        }
       
       
}
}

My chatProxy has a public  fMSConnectionService  variable that i can use to get the netConnection object.

Now, if i want to check for the success of my connection before i register the ChatProxy and ChatMediator. I would need to access the Service and call connect() from my ApplicationMediator and that is BAD from what i read, service should only be used by proxies.

What would be a good solution then ?

Thanks for the enlightment.
21  Announcements and General Discussion / General Discussion / Re: Concept Question, proxy and vo for a chat on: October 12, 2008, 10:16:32
Thanks for these clarifications, It must have been my Python heritage that fooled me: no Strong Typing no ide and Magic ponies.
22  Announcements and General Discussion / General Discussion / Concept Question, proxy and vo for a chat on: October 12, 2008, 03:20:39
Hi,

Firstly thank you for creating such a framework it forces good practices and unless you are a Pattern/OO wizard we need it !

I am new to AS3/Flex/pureMVC, in order to test my understanding of the framework i am trying to build yet an other chat with Flex/FMS and server side shared objects.

Please tell me if there is anything wrong in the following facts:
Simple case its a 1-1 chat.

- I dont need to store the messages received and typed in a messagesVO as an arrayCollection of String, i will just update the text widget of my Chat View Component by cummulating the chatmessage string attached to a notification sent by the proxy?

- I need a ChatProxy which will be an async remote proxy interfacing the remote shared object ?

- In a pureMVC jabber Chat demo around the author uses a custom chatEvent holding an id and a string, is there a need for custom events when we can pass Array as notification body. I guess there is an obvious use for it, but an example may be welcome.

PS:
If somehow i manage to build this small app after review i will add it to the contributions.

Thanks,
23  Announcements and General Discussion / Getting Started / Re: Courseware on: October 11, 2008, 04:01:10
Drooling for the demos,
best way to learn  ;D
Pages: 1 [2]