Flash
  Home arrow Flash arrow Page 3 - Communication and Security with the Flash ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Communication and Security with the Flash Communication Server
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2006-12-14

    Table of Contents:
  • Communication and Security with the Flash Communication Server
  • Sharing Data in Real Time
  • The Communication Classes
  • Firewalls and Security

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Communication and Security with the Flash Communication Server - The Communication Classes


    (Page 3 of 4 )

    Remote Methods

    In a typical application, an individual client may need to ask the server to perform some action on its behalf. For example, it may need to ask the server for the length of a recorded stream before playing it. The server may also have to ask the client to do something. For example, the server may need to have the client use a unique string provided by the server to name the streams the client will publish. Remote method calls are a way that the client and server can invoke methods on each other.

    An application instance can invoke a method on a client using the Client.call( ) method. A client can invoke a method on an application instance using the
    NetConnection.call( ) method. For example, a server-side script can invoke a method on an individual client in order to let the client know its unique ID number:

      client.call("setID", null, id);

    If a client method named setID( ) is invoked using Client.call( ) from the server, the method must be defined on the client’s NetConnection object or nothing will happen. For example, the client-side script might look like this:

      nc = new NetConnection();
      nc.setID = function (id) {
        myID = id;
      };

    Conversely, the client can call a method on the server using a NetConnection object:

      nc.call("getStreamLength", streamInfoResponder, streamName);

    For a result to be returned by the remote method, the second parameter passed to NetConnection.call( ) must be a object with an onResult( ) method.

    FlashCom also supports mechanisms to send a remote method request to multiple clients at the same time. Clients connected to the same shared object or playing the same stream can all receive a remote method call at the same time. For example, a popular way to update a text chat area is to use the send( ) method of a shared object to send a text message to every client:

      chat_so.send("showMessage", "Welcome to the chat.");

    In this case, a showMessage( ) method must be defined on the shared object or nothing will happen:

      chat_so.showMessage = function (msg) {
       
    chatTextArea.text += msg + '\n';
       
    chatTextArea.vPosition = chatTextArea.maxVPosition;
      };

    Chapter 9 describes calling and defining remote methods in detail.

    Communicating with Application Servers, Databases, and Directory Servers

    Flash and the Flash Communication Server often must work with other existing applications and resources. For example, users may have to log in against an existing directory service or database before being allowed to chat or view streams. Database systems can be used to store large amounts of information that FlashCom cannot easily manage, such as millions of records that represent the location of video messages in a video email system. Each record might contain the email text and the location of the recorded video message within a FlashCom application.

    Both the Flash Player and FlashCom can interact with web application servers and, through them, database and directory servers. The Flash client can call any server-side script available on a web server, send and receive XML data, access web services, and use the Flash Remoting gateway to more efficiently access application servers. In contrast, the Flash Communication Server (as of the latest version, 1.5.2) supports only Flash Remoting to connect to other servers. It cannot directly consume web services, send or receive XML, or call a CGI script, which often complicates designing applications that need to access a database or other service already available via a web server. However, Flash Remoting is a powerful and efficient technology that can be used with J2EE, ColdFusion, and .NET servers to provide access to databases or other services. Macromedia sells the Flash Remoting gateway separately for J2EE and .NET servers and bundles it with ColdFusion. There are also open source implementations of Flash Remoting for Perl, PHP, and Java. See Chapter 11 for more details on Remoting, and see http://opensource.org for information on open source code.

    Flash Remoting is a request/response technology that allows scripts in the Flash client or FlashCom to call remote methods on an application server. It uses HTTP to send and receive data in the AMF. Those remote methods can retrieve information from a database, directory server, or web server and return the information to FlashCom. From a developer’s point of view, Flash Remoting is easy to work with because complex ActionScript data is serialized and deserialized automatically. Flash Remoting can be used with or without FlashCom. The point is that Flash Remoting is flexible enough that it allows FlashCom to communicate effectively despite FlashCom’s lack of direct support for XML or server-side script access.

    Figure 1-5 illustrates some of the communication options for Flash and FlashCom. A Flash client can access a web application directly, as can FlashCom.

    In some cases, clients may connect to both an application server and FlashCom. In other cases, FlashCom may connect to the application server and provide information from or to its clients. When many clients need access to the same data, FlashCom should be used as an intermediary between application servers. Application performance will be improved by reducing the number of queries from each Flash


    Figure 1-5.  Both the Flash client and FlashCom can access application servers

    movie. When each movie needs to look up information unique to it, a direct connection to an application server is usually a better approach.

    More Flash Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming Flash Communication Server,"...
     

    Buy this book now. This article is excerpted from chapter one of the book Programming Flash Communication Server, written by Brian Lesser, Giacomo Guilizzoni, Robert Reinhardt, Joey Lott, and Justin Watkins (O'Reilly, 2005; ISBN: 0596005040). Check it out today at your favorite bookstore. Buy this book now.

    FLASH ARTICLES

    - Decorator Pattern
    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications
    - A Closer Look at Apollo`s File System API
    - Using the File System API
    - ActionScript 101
    - Flash Buttons
    - Advanced Flash Animation
    - Creating Your First Animated Movie with Flas...
    - Flash: Building Blocks






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT