6 min read

(For more resources on Flash, see here.)

Comparing SmartFoxServer Lite, Basic, and Pro

SmartFoxServer is a commercial product by gotoAndPlay(). There are three package options of SmartFoxServer. They are Lite version, Basic version, and Pro version. The demo license of the SmartFoxServer provides full features with 20 concurrent users maximum without time limitation. We will use the demo license to build the entire virtual world throughout the article.

SmartFoxServer Lite

The Lite version was the original SmartFoxServer since 2004. The maximum concurrent connection is limited to 50. It supports some core features like message passing, server-side user/room variables, and dynamic room creation.

However, the lack of ActionScript 3.0greatly limits the performance and functionality. Moreover, it is being updated slowly so that many new features from Basic and Pro version are missing in Lite version. When we compare the version number of the three options, we will know that Lite version is developing at a slow pace. The version of SmartFoxServer Pro is 1.6.6 at the time of writing. The Basic version is 1.5.9 and the Lite version is only 0.9.1.

Because of the slow update, not supporting ActionScript 3 and lack of features, it is not recommended to use Lite version in production.

SmartFoxServer Basic

SmartFoxServer Basic supports ActionScript 3 and a bunch of advanced features such as administration panel, game room spectators, and moderators. The administration panel lets moderators configure the zones, rooms, and users when the server is running. However, the lack of server-side extension support limits the customizability of the socket server. It also means that all logic must reside on the client side. This raises a security issue that the client may alter the logic to cheat.

The Basic version provides enough features to build a Flash virtual world in small scale that does not require high security. If you need a specific server logic and room management or want to put logic in server side to prevent client-side cheating, Pro version is the choice.

SmartFoxServer Pro

There is a long list of features that are supported in Pro version. There are three features amongst all that distinguish the Pro version, they are:

  • Server-side extension that modifies the server behavior
  • JSON/Raw data protocol message passing
  • Direct database connection

Modifying the behavior of server

Server-side extension is some server logic that developers can program to modify the default behavior of the internal event handler and add server-side functions to extend the server for specific usage.

For example, we may want to override the “user lost” event so that we can save the user properties, telling others that someone is disconnected and something else. In this case, we can write a function in server-side extension to handle all these things when the user lost, instead of running the default behavior that was provided by SmartFoxServer.

The SmartFoxServer is written in Java. Therefore the native support language of server-side extension is Java. In order to reduce the development difficulties, SmartFoxServer supports Python and ActionScript as a server-side extension. The support of ActionScript makes it much more convenient for most Flash developers to develop the server-side extension without even knowing Java.

Please note that the version of ActionScript supported in server-side extension is ActionScript 1, instead of ActionScript 3.

Take a look at the following code snippet on a server-side extension. The functions in server-side extensions are often similar to this one. It comes with arguments to know which user is calling this command at which room. In this snippet there is a command called getSomething and it will use the provided command parameters to get the result and return the result to the corresponding user.


function handleRequest(cmd, params, user, fromRoom)
{
var response = {};
switch (cmd)
{
case "getSomething":
var cpu = params['cpuType’];
response.something = "A Powerful Computer with CPU "+cpu;
// send the response back to the client.
_server.sendResponse(response,-1,null,[user]);
break
}
}

JSON/Raw data protocol

JSON (http://www.json.org) is a light-weight text-based data-interchange format. It is designed for both humans and machines to read and write the data easily. For example, we can format a list of users and their information with the following JSON code.

{"users": [
{
"name" : "Steve",
"level" : 12,
"position" : {
"x" : 6,
"y" : 7
},
{
"name" : "John",
"level" : 5,
"position" : {
"x" : 26,
"y" : 12
}
}

The default data protocol supported by SmartFoxServer Lite and Basic is XML. The Pro version added support of JSON and raw data protocol make it possible to compress the transfer of data between clients and server. The length of messages between clients and server is much shorter and it means the transmission speed is much faster.

Take an example of a client sending data to a server with different protocols.

We are now trying to fetch some data from the server, and this is what it looks like when sending a command to the server via different protocol.

  • XML:

    <dataObj><var n=’name’ t=’s’>extension</var><var n=’cmd’
    t=’s’>getSomething</var><obj t=’o’ o=’param’><var n=’cpuType’
    t=’n’>8</var></obj></dataObj>

    The length of this command is 148 bytes.

  • JSON:

    {"b":{"p":{"cpuType":8},"r":1,"c":"getSomething","x":"extension"},
    "t":"xt"}

    The length of this command is 75 bytes.

  • Raw Data:

    %xt%extension%getSomething%8%

    The length of this command is 29 bytes.

When comparing with the bytes used to send a command over the network, XML is two times the JSON and five times the raw protocol. We are talking about several byte differences that may not be considered in a broadband Internet. However, it is a must to consider every byte that was sent to the network because we are not talking about 29 bytes versus 148 bytes in the real applications. Imagine there are 2000 players in the virtual world, sending similar commands every second. We are now talking about 2.4Mbit/s versus 500Kbit/s, and this rough statistic already ignores those commands that fetch a long list of results, for example, a long list of items that are owned by the player.

The raw protocol format takes less bytes to represent the command because it does not contain the field name of the data. All parameters are position-dependent. In the preceding command, the first parameter stands for an extension message and the second stands for the command name. Other command-specific parameters follow these two parameters.

Raw protocol is position-dependent on the passing parameters while JSON is not. It is recommended to use JSON protocol in most case and use the raw data protocol in real-time interaction parts. Also, we should state clearly in comments code what each parameters stands for because others cannot get the field information from the raw data.

Accessing the database directly

Flash does not provide any database access functions. Flash applications always connect to database via server-side technique. The Pro version of SmartFoxServer provides direct database connectivity in server-side extension. The Flash virtual world will call a function in sever-side extension and it will handle the database connection for the Flash.

As the database connectivity is handled in server-side extension, Basic and Lite version does not contain this handy feature. We have to wrap the database access in other server-side technique, such as PHP, to connect database in Basic and Lite version.

The two graphs compare the architecture of the database access in SmartFoxServer Pro, Basic, and Lite.

LEAVE A REPLY

Please enter your comment!
Please enter your name here