<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html" />
  <link rel="self" type="application/atom+xml" href="http://www.insideria.com/atom.xml" />
  <id>tag:www.insideria.com,2009://34/tag:www.insideria.com,2009://34.37310-</id>
  <updated>2009-11-16T14:53:38Z</updated>
  <title>Comments for Building a Simple Chat App With Adobe Flash Collaboration Services (http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2009://34.37310</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=37310" title="Building a Simple Chat App With Adobe Flash Collaboration Services" />
    <published>2009-06-26T02:28:24Z</published>
    <updated>2009-06-26T03:05:24Z</updated>
    <title>Building a Simple Chat App With Adobe Flash Collaboration Services</title>
    <summary>In this post, we will focus on getting started with Adobe Flash Collaboration Services (formerly Cocomo).   If you&apos;ve heard of this, but aren&apos;t really sure what it is, AFCS is a hosted service provided by Adobe which enables real-time collaboration within your own Flex applications.</summary>
    <author>
      <name>Andrew Trice</name>
      
    </author>
    
    <category term="Blogs" />
    
    <content type="html" xml:lang="en" xml:base="http://www.insideria.com/">
      <![CDATA[<p>In this post, we will focus on getting started with <a href="http://labs.adobe.com/technologies/afcs/" target="_blank" >Adobe Flash Collaboration Services</a> (formerly Cocomo).   If you've heard of this, but aren't really sure what it is, AFCS is a hosted service provided by Adobe which enables real-time collaboration within your own Flex applications.

<p>A better description from the <a target="_blank"  href="http://labs.adobe.com/technologies/afcs/">AFCS site on Adobe Labs</a>:
<blockquote>Adobe Flash Collaboration Service is a Platform as a Service that allows Flex developers to easily add real-time social capabilities into their RIA (rich Internet applications). Comprised of both Flex-based client components and a hosted services infrastructure, Adobe Flash Collaboration Service allows you to build real-time, multi-user applications with Flex in less time than ever before. And because Acrobat.com hosts the service, issues like deployment, maintenance, and scalability are taken care of for you.</blockquote>

<p>This can be used for live chats, video chats, whiteboarding, and real-time collaboration, and is very easy to get started.    Below, you'll find a quick example that I was able to put together this evening.

<p>This example uses the default authentication provided by AFCS (requires and AFCS account), however you can override this to create your own authentication.  In this example, you must use your Adobe AFCS username and password to log in:

<p><iframe src="http://www.tricedesigns.com/portfolio/afcs/" width="100%" height="400"></iframe>

<p>In case you don't want to create an account and log in, here's what the UI looks like once you have logged in.  It is really just a basic chat application:

<p><img src="http://content.screencast.com/users/triceam/folders/Jing/media/a33b08f1-3b63-43e6-ac92-bdd80358051d/2009-06-25_2237.png" />

<p>This is a simlpe example, which I started by taking the "Simple Chat" example that comes with the AFCS SDK, and started playing around with it.

<p>To get started, This first thing that you need to do is sign up for an account, and download the SDK at <a target="_blank" href="https://cocomo.acrobat.com/">https://cocomo.acrobat.com/</a>.  

<p>Once you have created an account and logged in, just click on the "Download SDK" button at the top of the screen.   This will contain everything you need to get started... the swc libraries, documentation, and code examples.    

<p>I was able to put together this chat application in just minutes, after getting familiar with the API through the provided examples and documentation.   The full source code is below.   I changed very little from the original example...   I just added a form that allows you to enter your user name and password, and used Panels to clean up the UI.

<p>The two main AFCS components in this example are the AdobeHSAuthenticator, which is used to authenticate the AFCS accout, and the ConnectSessionContainer, which is used to contain the chat elements.
    

<p><div class="acode" style="overflow: auto; padding: 10px;" ><div style="overflow-x: visible;"> 
<code language="perl">
<pre>
&lt;?xml <span class="category2">version</span>="<span class="quote">1.0</span>" encoding="<span class="quote">utf-8</span>"?&gt; 
&lt;mx:<span class="category2">Application</span> 
  xmlns:mx="<span class="quote">http://www.adobe.com/2006/mxml</span>" layout="<span class="quote">absolute</span>" 
  xmlns:rtc="<span class="quote">AfcsNameSpace</span>"&gt; 
  
  &lt;mx:Script&gt;
    &lt;![CDATA[
      <span class="category1">import</span> com.adobe.rtc.pods.simpleChatClasses.ChatMessageDescriptor;
      <span class="category1">import</span> com.adobe.rtc.events.ChatEvent;
      <span class="category1">import</span> com.adobe.rtc.pods.simpleChatClasses.SimpleChatModel;
      
      <span class="linecomment">// This simple example just shows how this shared model can be made easily bindable for MXML.</span>
      <span class="linecomment">// See SimpleChatModel for details.</span>
      
      [Bindable]
      <span class="category1">public</span> <span class="category1">var</span> chatModel:SimpleChatModel;
      protected <span class="category1">function</span> buildModel():<span class="category1">void</span>
      {
         <span class="linecomment">// Create the model: just calling the constructor won't create the collection node or pass the messages.</span>
         <span class="linecomment">// Call subscribe and give it a shared ID while creating the model. </span>
         <span class="linecomment">// The shared ID becomes the name of the collection node.</span>
         chatModel = <span class="category1">new</span> SimpleChatModel();
         chatModel.sharedID = "<span class="quote">myChat_SimpleChatModel</span>";
         
         chatModel.subscribe();
         chatModel.addEventListener(ChatEvent.HISTORY_CHANGE, onChatMsg);
         <span class="category1">this</span>.addEventListener(KeyboardEvent.KEY_UP, onKeyStroke);
       }
      
      protected <span class="category1">function</span> submitChat(str:<span class="category2">String</span>):<span class="category1">void</span>
      {
         <span class="category1">var</span> cmd:ChatMessageDescriptor = <span class="category1">new</span> ChatMessageDescriptor();
         cmd.displayName = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID).displayName;
         cmd.msg =  str;
         chatModel.sendMessage(cmd);
         chat_mesg_input.<span class="category2">text</span> = "<span class="quote"></span>";
       }
      
      protected <span class="category1">function</span> clearChat():<span class="category1">void</span>
      {
         chat_mesg_area.<span class="category2">text</span> = "<span class="quote"></span>";
         chatModel.<span class="category2">clear</span>();
       }
      
      protected <span class="category1">function</span> onChatMsg(p_evt:ChatEvent):<span class="category1">void</span>
      {
         <span class="category1">if</span>(p_evt.<span class="category2">message</span> != <span class="category1">null</span> &amp;&amp; p_evt.<span class="category2">message</span>.msg != <span class="category1">null</span> &amp;&amp; p_evt.<span class="category2">message</span>.displayName != <span class="category1">null</span>)
           chat_mesg_area.<span class="category2">text</span> += "<span class="quote">\r\n</span>" +  p_evt.<span class="category2">message</span>.displayName + "<span class="quote">: </span>" + p_evt.<span class="category2">message</span>.msg;
         <span class="category1">else</span>
           chat_mesg_area.<span class="category2">text</span> = "<span class="quote"></span>";
       }
      
      protected <span class="category1">function</span> onKeyStroke(p_evt:KeyboardEvent):<span class="category1">void</span>
      {
         <span class="category1">if</span>(p_evt.keyCode == Keyboard.<span class="category2">ENTER</span>) {
            submitChat(chat_mesg_input.<span class="category2">text</span>);
          } 
       }
      
      <span class="category1">private</span> <span class="category1">function</span> doLogin() : <span class="category1">void</span>
      {
         auth.userName = username.<span class="category2">text</span>;
         auth.<span class="category2">password</span> = <span class="category2">password</span>.<span class="category2">text</span>;
         cSession.login();
         loginForm.<span class="category2">enabled</span> = <span class="category1">false</span>;
       }
      
      <span class="category1">private</span> <span class="category1">function</span> onAuthSuccess( event : Event ) : <span class="category1">void</span>
      {
         vs.selectedIndex = 1;
         buildModel();
       }
      
      <span class="category1">private</span> <span class="category1">function</span> onAuthfail( event : Event ) : <span class="category1">void</span>
      {
         loginForm.<span class="category2">enabled</span> = <span class="category1">true</span>;
       }
      
    ]]&gt;
  &lt;/mx:Script&gt;
  
  &lt;rtc:AdobeHSAuthenticator 
    authenticationSuccess="<span class="quote">onAuthSuccess(event)</span>"
    authenticationFailure="<span class="quote">onAuthfail(event)</span>"
    id="<span class="quote">auth</span>"  /&gt;
    
  &lt;mx:ViewStack 
    id="<span class="quote">vs</span>"
    top="<span class="quote">10</span>" left="<span class="quote">10</span>" right="<span class="quote">10</span>" bottom="<span class="quote">10</span>" &gt;
    
    &lt;mx:Canvas <span class="category2">width</span>="<span class="quote">100%</span>" <span class="category2">height</span>="<span class="quote">100%</span>" &gt;
      &lt;mx:Panel title="<span class="quote">Login:</span>"
            horizontalCenter="<span class="quote">0</span>"
            verticalCenter="<span class="quote">0</span>"
            id="<span class="quote">loginForm</span>"
            defaultButton="<span class="quote">{ login }</span>"&gt;

        &lt;mx:Form&gt;

          &lt;mx:FormItem <span class="category1">label</span>="<span class="quote">Username:</span>" <span class="category2">width</span>="<span class="quote">100%</span>"&gt;
            &lt;mx:TextInput id="<span class="quote">username</span>" <span class="category2">width</span>="<span class="quote">100%</span>"/&gt;
          &lt;/mx:FormItem&gt;


          &lt;mx:FormItem <span class="category1">label</span>="<span class="quote">Password:</span>"  <span class="category2">width</span>="<span class="quote">100%</span>"&gt;
            &lt;mx:TextInput id="<span class="quote">password</span>" <span class="category2">width</span>="<span class="quote">100%</span>" displayAsPassword="<span class="quote">true</span>"/&gt;
          &lt;/mx:FormItem&gt;

        &lt;/mx:Form&gt;

        &lt;mx:ControlBar horizontalAlign="<span class="quote">right</span>"&gt;
          &lt;mx:<span class="category2">Button</span> id="<span class="quote">login</span>"
                 <span class="category1">label</span>="<span class="quote">Login</span>"
                 <span class="category2">enabled</span>="<span class="quote">{ username.text.length &amp;gt; 0 &amp;amp;&amp;amp; password.text.length }</span>"
                 click="<span class="quote">doLogin()</span>"/&gt;
        &lt;/mx:ControlBar&gt;


      &lt;/mx:Panel&gt;
    &lt;/mx:Canvas&gt;
    
    &lt;rtc:ConnectSessionContainer roomURL="<span class="quote">put your room url here</span>"
                   id="<span class="quote">cSession</span>"
                   authenticator="<span class="quote">{auth}</span>"
                   <span class="category2">width</span>="<span class="quote">100%</span>"
                   <span class="category2">height</span>="<span class="quote">100%</span>"
                   autoLogin="<span class="quote">false</span>"&gt;

      &lt;mx:Panel <span class="category2">width</span>="<span class="quote">100%</span>" <span class="category2">height</span>="<span class="quote">100%</span>"  title="<span class="quote">Simple Chat</span>"&gt;
        &lt;mx:TextArea <span class="category2">width</span>="<span class="quote">100%</span>"
               <span class="category2">height</span>="<span class="quote">100%</span>"
               id="<span class="quote">chat_mesg_area</span>"/&gt;

        &lt;mx:ControlBar&gt;
          &lt;mx:TextInput <span class="category2">width</span>="<span class="quote">100%</span>"  id="<span class="quote">chat_mesg_input</span>"/&gt;

          &lt;mx:<span class="category2">Button</span> <span class="category1">label</span>="<span class="quote">Submit Chat</span>" click="<span class="quote">submitChat(chat_mesg_input.text)</span>"/&gt;
          &lt;mx:<span class="category2">Button</span> <span class="category1">label</span>="<span class="quote">Clear Chat</span>" click="<span class="quote">clearChat()</span>"/&gt;

        &lt;/mx:ControlBar&gt;
      &lt;/mx:Panel&gt;
    &lt;/rtc:ConnectSessionContainer&gt;
    
  &lt;/mx:ViewStack&gt;  
    
  
&lt;/mx:<span class="category2">Application</span>&gt; </pre>
</code>
 
</div></div> 


<p>___________________________________<br/>
<strong>Andrew Trice</strong><br/>
Principal Architect<br/>
<a href="http://www.cynergysystems.com" target="_blank">Cynergy Systems<br/>
http://www.cynergysystems.com</a>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067220</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067220" />
    <title>Comment from Nigel Pegg on 2009-06-25</title>
    <author>
        <name>Nigel Pegg</name>
        <uri>http://blogs.adobe.com/collabmethods/</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://blogs.adobe.com/collabmethods/">
        <![CDATA[<p>One thing I know we need to do better is explain that your apps absolutely DO NOT require users to have an Adobe/AFCS account. You can set up your rooms to allow guests to come in with only their usernames, or hook up your own backend authentication systems to us, and let your users in that way, with the roles and permissions you want them to have. We definitely don't want to force your users to get identities w/ us. We're actually working on a new drop of the SDK with better docs / examples, to make this easier to do.</p>

<p> Thanks for the tutorial!</p>

<p>   nigel</p>]]>
    </content>
    <published>2009-06-26T06:01:47Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067221</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067221" />
    <title>Comment from Andrew Spaulding on 2009-06-25</title>
    <author>
        <name>Andrew Spaulding</name>
        <uri>http://www.flexdaddy.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.flexdaddy.com">
        <![CDATA[<p>Don't forget you can also use the SimpleChatPod which will allow for one-to-one communications between chat users, and will also persist the chat content as well ... offers some nice management of chat content :-)</p>]]>
    </content>
    <published>2009-06-26T06:06:00Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067223</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067223" />
    <title>Comment from Mário Santos on 2009-06-26</title>
    <author>
        <name>Mário Santos</name>
        <uri>http://www.msdevstudio.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.msdevstudio.com">
        <![CDATA[<p>Hu? That's all? only those lines of code? </p>

<p>Nice!</p>

<p>Adobe is making things simpler that ever!</p>]]>
    </content>
    <published>2009-06-26T07:00:51Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067421</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067421" />
    <title>Comment from Dan Orlando on 2009-06-29</title>
    <author>
        <name>Dan Orlando</name>
        <uri>http://danorlando.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://danorlando.com">
        <![CDATA[<p>Great post Andrew. It's good to finally see some tutorials on AFCS getting out there.</p>]]>
    </content>
    <published>2009-06-29T20:07:26Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067423</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067423" />
    <title>Comment from Andrew Trice on 2009-06-29</title>
    <author>
        <name>Andrew Trice</name>
        <uri>http://www.tricedesigns.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.tricedesigns.com">
        <![CDATA[<p>Thanks Dan, AFCS is a big unknown to a lot of people out there.   I'm thinking about doing a few more posts on it, as i dig deeper myself.</p>]]>
    </content>
    <published>2009-06-29T20:21:20Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067479</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067479" />
    <title>Comment from Ed on 2009-06-30</title>
    <author>
        <name>Ed</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Can this be done in Flash CS4 or is this only available to Flex 3 users?</p>]]>
    </content>
    <published>2009-06-30T14:57:37Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067480</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067480" />
    <title>Comment from Ed on 2009-06-30</title>
    <author>
        <name>Ed</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Can this be done in Flash CS4 or is this only available to Flex 3 users?</p>]]>
    </content>
    <published>2009-06-30T15:00:23Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067481</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067481" />
    <title>Comment from Ed on 2009-06-30</title>
    <author>
        <name>Ed</name>
        <uri>http://www/banditfly.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www/banditfly.com">
        <![CDATA[<p>Can this be done in Flash CS4 or is this only available to Flex 3 users?</p>]]>
    </content>
    <published>2009-06-30T15:02:18Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.37310-comment:2067817</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.37310" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/06/building-a-simple-chat-app-wit.html#comment-2067817" />
    <title>Comment from sandeep on 2009-07-05</title>
    <author>
        <name>sandeep</name>
        <uri>http://connectnow.acrobat.com/divi04</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://connectnow.acrobat.com/divi04">
        <![CDATA[<p>its not working in my system i have kept lib path to cocomo sdk also can you help me i am getting login box but after entering my id and password it is not going into next state,,...</p>]]>
    </content>
    <published>2009-07-06T05:56:55Z</published>
  </entry>

</feed
