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 wayMyapp.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.