Book Image

Flash Multiplayer Virtual Worlds

Book Image

Flash Multiplayer Virtual Worlds

Overview of this book

Flash virtual worlds are some of the most exciting—and profitable—online business being built today. Using Flash, developers can build interactive environments where users can interact with the virtual world and one another, compete, and have fun. Creating a playful environment on an electronic network presents unique challenges as you combine a fun, upbeat frontend with some serious and complex server logic. This handy book assists you in building amazing virtual worlds in no time by implementing ActionScripts in a Flash IDE. With this book in hand, you will build virtual worlds that have avatars walking around and interacting with non playing characters, completing challenging quests, and allowing users to link with real-world friends. The fun begins with first exploring existing virtual world games such as Club Penguin, Mole, Dofus, and World of Warcraft. We will then design our virtual environment. Then we will create avatars and move the avatars in the virtual world. We will add some triggers to add amusement and life to the virtual world. We will allow the avatars to interact with other players and create a buddy list for each user. Then we will integrate buildings and other environment to the virtual world. We will also let the players interact with non-player characters to complete some tasks. Finally, we move on to add interesting quests to the virtual world, which need to be accomplished by the player to gear up to the next level of the game. This example-rich, hands-on guide sequentially develops a multiplayer virtual world—the platform, the environment, quests, avatars, non-playing characters, and interaction between them.
Table of Contents (18 chapters)
Flash Multiplayer Virtual Worlds
Credits
About the Author
About the Reviewers
Preface

Available socket servers for Flash


There are several socket servers on the market that fit the development of Flash virtual world. Some are good at media streaming while some are powerful on user management.

SmartFoxServer

SmartFoxServer (http://smartfoxserver.com/) was developed by gotoAndPlay(). It is a socket server for Flash that provides powerful tools and resource management to enable highly productive development of virtual worlds and multiplayer games.

It was designed for Flash originally and now it also provides a set of API for iPhone, .Net, Java, Silverlight, and even Ajax. It also supports media streaming function by embedded open source Flash media server called Red5.

It also supports clustering through terracotta, an open source clustering software. The logic is distributed into clustered servers and enables the ability to extend the scalability and enhances the failure resiliency. The server comes with fully-documented resources with lots of tutorials for beginners. There is also an active forum to get support.

SmartFoxServer provides different licenses and connection options for developers. It provides Lite, Basic, and Pro options with maximum connections from 100 to unlimited. The Lite version is free with maximum 50 concurrent connections and Basic or Pro version are free for up to 20 concurrent connections. Also the Pro version provides an add-on module called BlueBox (http://smartfoxserver.com/products/blueBox.php) to allow connection behind firewalls and proxies via HTTP-tunneling.

However, it will be a little expensive as the server costs $2000 Euros for SmartFoxServer Pro and $400 Euros for the BlueBox add-on with unlimited connections.

ElectroServer

ElectroServer (http://www.electro-server.com/) is another mature virtual world server for Flash that was developed by Electrotank in 2001. Similar to SmartFoxServer, ElectroServer provides powerful tools and fits the development of Flash virtual world server.

ElectroServer also provides scalability by load balancing with multiple gateway servers. The gateway servers are used to handle the clients' connections I/O and the logic is kept in one server. ElectroServer also provides media streaming features.

There are two packages with different media connections and concurrent player options available. The costs of ElectroServer can be expensive. Prices start from $700 to $72K depending on the package option. The professional version is free up to 25 concurrent connections.

Flash Media Interactive Server

Flash Media Interactive Server (http://www.adobe.com/products/flashmediainteractive/) was developed by Adobe and aims to provide video streaming and real-time communication between different Flash player clients. Flash Media Interactive Server mainly targets real-time streaming and communicating technology that can stream videos with different popular codec and live stream. It supports features such as server-side ActionScript extension and server-side shared objects to make it possible for virtual world development.

This server provides clustering by edge/origin load balancing. Logic is kept in the origin server and clients connect to different edge servers, then edge servers connect to the origin server. It is like the gateway approach from ElectroServer.

However, the lack of game room management and game-related features means that developers have to write their own game management scripts.

Flash Media Interactive Server costs $4500 for unlimited connections.

Red5

Red5 (http://red5.org/) is one of the open source Flash socket servers that provides basic server-side features such as real-time protocol and shared memory. It aims to become an open source alternative of Flash Media Interactive Server and thus it is more powerful on video streaming than virtual world resources management.

Red5 uses edge/origin clustering that is similar to the Flash Media Interactive Server while using the open source Terracotta solution.

As an alternative of Flash Media Server, it also lacks server-side game management features. However, as it is open source, you can extend the functionality of Red5 to fit your idea of the virtual world.

Writing your own socket server

Most Flash servers in the market provide extensibility for developers. However, available servers may not fit your budget or design ideas. As an alternative solution, you can program your own socket server to handle Flash connections. The socket server is usually written in C++ or Java. What a virtual world server does is handle all connections and manage all zone, room, and user resources via a predefined protocol. There are some resources from Internet that discuss how to develop a socket server. There is an old article (http://gotoandplay.it/_articles/2003/12/xmlSocket.php) from gotoAndPlay() that introduced the basic concept of implementing a socket server that connects Flash. Although the article used an old version of Flash and the XML socket instead of the binary socket, it is a good starting point to learn the concept before developing the socket server. In a real case, two friends of mine implemented a Flash server in Java for one year and now they are working on several multiplayer games in it.

Choosing the right server

 

SmartFox Server 1.6

ElectroServer 4

Flash Media Server 3.5

Red5 0.9

Virtual world architecture (Zoon/Room)

Very good

Very good

Bad

Bad

Media Streaming

Good

Good

Very good

Good

Supports Client

Flash, iPhone, JAVA, Unity, .Net

Flash

Flash

Flash

Connections for development

20

25

10

Unlimited

Maximum Connections

Unlimited

200,000

Unlimited

Unlimited

Clustering

Logic distributed without single-point failure clustering

Gateway approach with logic in one server

Gateway approach with logic in one server

Gateway approach with logic in one server

Firewall Traversal

BlueBox HTTP-tunneling

HTTP-tunneling

RTMPT HTTP-tunneling

RTMPT HTTP-tunneling

Cost

Average

Average to expensive

Expensive

Free

Either SmartfoxServer or ElectroServer fits the development of virtual world the most. They all provide solid zone, room, and user managements, and they are ready for extension and can scale big when the virtual world grows.

Note

Throughout this book, all examples will be based on SmartFoxServer. We choose SmartFoxServer because it supports not only Flash but also iPhone, Unity, Java, and .Net. This keeps the flexibility to extend and spread the virtual world to other platforms with less effort.