Programming Flash Communication Server Brian Lesser, Giacomo Guilizzoni, Joey Lott, Robert Reinhardt, and Justin Watkins O'REILLY 4 Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo
Table of Contents Foreword Preface xi xv Part I. FlashCom Foundation 1. Introducing the Flash Communication Server 3 Clients and Servers. 4 Creating an Application 6 Real-Time Messaging Protocol 7 The Communication Classes 9 Communicating with Application Servers, Databases, and Directory Servers 15 Firewalls and Security 16 ' Getting Started 16 Hello Video! ' 19 Conclusion 30 2. Communication Components 32 Overview of Communication Components 33 Summary of Communication Components 38 Creating an Application that Monitors a Connection 70 Building a Simple Chat Room ' 72 Adding Audio and Video to the Chat Room 73 Forgoing the SimpleConnect Component 75 Conclusion 76
3. Managing Connections 78 Making a Connection 78 Managing a Connection ' 84 Reusing a NetConnection Object 90 Multiple Simultaneous NetConnection Objects 93 Testing and Debugging Network Connections 93 Subclassing the NetConnection Class 96 Communication Components Without SimpleConnect 104 Conclusion 112 4. Applications, Instances, and Server-Side ActionScript 113 Scripting Application Instances 113 Differences Between Flash ActionScript and Server-Side ActionScript 118 The Life of an Application Instance 124 Running a Simple Hello World Test Script 126 A More Realistic Example 131 Instance-to-instance Communications ' - 138 Script Filenames and Locations in Detail 140 Testing and Debugging Server-Side Script Files 143 Designing Communication Applications 145 Conclusion 145 Part II. Audio, Video, and Data Streams 5. Managing Streams 149 A Simple Publisher/Subscriber Example 151 Stream Names 157 Publishing Streams in Detail 158 Playing Streams in Detail 166 The Stream Class. 183 Publishing and Playing ActionScript Data 192 Creating Synchronized Presentations 197 The NetStream and Stream Information Objects 200 Stream Enhancements and Limitations 203 Conclusion.. 204 6. Microphone and Camera 206 Working with Microphone/Audio Input 206 Working with Camera Input 216 vi I Table of Contents
Building a Message-Taking Application."- 225 Building a Surveillance Application 233 Conclusion 237 7. Media Preparation and Delivery 238 Audio and Video Compression 238 Converting Prerecorded Material to FLV Format 242 Using Flash Pro's Media Components 260 Enabling Multiple Bit Rate FLVs Within an Application 267 Streaming MP3 Audio 273 Conclusion 276 Part III. Remote Connectivity and Communication 8. Shared Objects 281 Objects and Shared Objects 281 Getting a Shared Object in Flash 282 Updates and Frame Rates 296 Scripting Shared Objects on the Server 298 Temporary and Persistent Shared Objects 303 Proxied Shared Objects 315 Shared Objects and Custom Classes 321 Avoiding Collisions ' 324 Optimizing Shared Object Performance 325 Broadcasting Remote Method Calls with send() 326 A Simple Video and Text Chat Application 328 Conclusion 335 9. Remote Methods 336 Why Use Calls? 336 The send() and call() Methods 337 Client-to-Server Calls 337 Server-to-Client Calls 343 Server-to-Server Calls 346 A Simple Lobby/Rooms Application 347 Debugging Calls ' 3 6 3 Advanced Topics 366 Conclusion 380 Table of Contents I vii
10. Server Management API 381 Connecting to the Admin Service,. 381 Using the Server Management API 386 Server Management API Uses 400 Conclusion 406 11. Flash Remoting :.. 407 The Remoting Gateway 407 Remoting Basics 409 Role of Remoting in FlashCom Applications. 425 Securing Access, 430 Conclusion 431 12. ColdFusion MX and FlashCom.432 Understanding ColdFusion MX and Flash Remoting 432 Using Flash Remoting to Log Events 438 Getting a List of Streams 450 Using ColdFusion and FTP to Mirror Streams 460 Conclusion 468 Part IV. Design and Deployment 13. Building Communication Components 471 Source Files 474 People Lists 474 A Simple People List 474 Listenable Shared Objects 485 Status and People List 489 Text Chat 507 Shared Text. 519 Video Conference and Video Window 527 PeopleGrid, 538 Summary 545 Conclusion 547 14. Understanding the Macromedia Component Framework 548 The Component Framework 548 Under the Hood of the Chat Component 550 Creating a Simple Component from Scratch: SharedTextlnput 562 viii Table of Contents
Creating a Container Component: SharedAddressForm 570 Creating an Authenticating Component 574 Integrating Components with Your Existing Applications 586 Understanding the Framework 593 Conclusion 611 15. Application Design Patterns and Best Practices 612 Shared Object Management 612 Moving Code to the Server 637 Building Facades on the Server 642 Server-Side Client Queues 643 A Framework for Recording and Playing Back Componentized Applications 646 Components and Component Frameworks 660 Conclusion 671 16. Building Scalable Applications 672 Coordinating Instances 673 Scalability and Load Balancing 686 Conclusion 695 17. Network Performance, Latency, and Concurrency 697 Latency 698 Bandwidth 704 Concurrency 720 Conclusion 725 18. Securing Applications 726 The Three A's: Authentication, Authorization, and Accounting 727 Authentication 728 Authorization 764 Accounting 784 Suggestions and References 790 Conclusion 792 About the Authors 793 Index 795 Table of Contents