Smartfoxserver



Welcome to the SmartFoxServer 2X online documentation. Please choose a topic in the left menu to get started. Updated C# API setup documentation and introduction to Unity examples. Updated AdminTool documentation: new tutorial showing how to create custom administration modules. I have started to use SmartFoxServer 2x. I used to use SmartFoxServer Pro, but I decided that I should use HTML5, so I did it. Anyway, there is a problem with Database Manager. First, I will tell you. SFS2X Docs / ExamplesJS / connector » Connector » Overview. The Connector example is the most simple application you can create: it just shows how to set the client configuration and connect to SmartFoxServer 2X. The SmartFoxServer 2X client API allows the connection details to be set in a configuration object passed to the main API class (SmartFox) constructor.

  1. Smartfoxservers
  2. Smartfoxserver Tutorial
  3. Smartfoxserver
  4. Smartfoxserver Hosting

So, without further ado let’s dive. My software at the time of writing this article is Unity3D 5.0.1, Java 1.7, Eclipse, and SmartFoxServer’s own Community Edition v2.9, and Client API C# API for Unity 5(which is in beta atm) in a Windows 8.1 machine. I picked the x64 versions that were provided.

SmartFoxServer installation

Start by installing SmartFox. After the EULA, a message warns us that the installation folder needs Administrator privilages. To accomodate that I choose to make the installation at my user folder eg. C:UserskonsnosSmartFoxServer. Next I unchecked Install as service. If you are going for production I suggest you keep it ticked but for now we’re going for development use. Install as service will be a problem when we want to close and restart to apply the changes we do to the server, so I really don’t recommend it for development.

After the installation is complete SmartFox can be opened via the sfs2x-standalone.exewhich is inside the folder SFS2X. Now open a new tab in your browser and point to http://localhost:8080/admin/ . If you can see a flash page asking you user name and password then the installation process went fine. Log in credentials for Host is localhost, port 9933, Username is sfsadmin and Password sfsadmin. And you’re in! I’m not going a deep explanation here of how SmartFox works but in order to know your way around, the basic usage comes from the Administration modules at the left.

For the beta version that I use a patch must be installed, to make this work for Unity5. As per SmartFox’s documentation this will be obsolete in SmartFoxServer 2X v2.10. But for our case extract the client API to a folder and copy the _patch folder, patcher.jar, install-win.bat anddeploy.data.txt to our SFS2X folder inside your installation location. Double click thepatcher.jar and a window will pop up with the successful or failure message. Restart SmartFox standalone if it’s already open. Also re-login in the admin panel. The server version at the top should now be 2.9.3. We can now delete the files and folder we moved in our installation location (for the sake of clean up).

Unity3D project

Open Unity3D and create a project. I created a 3D project with the name Networking Example. When the new project is open, in the Project pane create a folder named Plugins and move the file APIDebugUnitySmartFox2X.dll there. Again we are using a debug file. In production feel free to use the Release file. The difference is in the debug logs which the Release file doesn’t include.

Smartfoxservers

Now that we have the API included we should start writing some SmartFox code. In our Assets folder we create a C# Script file ConnectionManager and another one named ConnectionInitializer. Copy paste the code for ConnectionManager and ConnectionInitializer. The ConnectionManager script handles SmartFox while the ConnectionInitializer is for testing it. I have tried to add descriptive comments but if you have any enquiry feel free to ask me.

Now in Unity create a new GameObject and add the script ConnectionInitializer as a component. Make sure that sfs2x-standalone is running and you can log in in the Admin Panel. Then press Play in Unity. As you can see in my logs I had a successful connection. However the log in failed. The log says the requested zone doesn’t exist, which happens because we haven’t created it yet. As for the security exception we haven’t provided any policy file yet, and we won’t for this tutorial as it isn’t needed for testing.

SmartFoxServer Setup

It’s time to get our hands dirty with the server. I’m using as I said earlier Eclipse so let’s create a new Java Project. Name it WorldExtension, and press Next. In the next window, Java Settings, we shall add SmartFoxServer libraries, so head into the tab Libraries, press Add External JARs, and locate the files sfs2x.jar and sfs2x-core.jar from the folder Installation_DirectorySmartFoxServer_2XSFS2Xlib. Finally click Finish.

Note: If you are new to Eclipse, or you just installed it, when you press Finish button nothing will happen. At least nothing visible. Try clicking the Restore icon at the left of the window and the project shall be revealed.

It’s time to write some code. In the src folder create a new class and name itWorldExtension. You may add from that window, as a Superclass the SFSExtension from com.smartfoxserver.v2.extensions or you can write it by yourself in code. Since we are at it, create another class with the name ForwardHandler, which will have as a Superclass the BaseClientRequestHandler, from the namespace com.smartfoxserver.v2.entities.User. Finally the same as ForwardHandler, create HaltHandler.

Note: Always suffix your project name with the Extension text. SmartFoxServer needs it that way. It will make your life easier.

The Superclasses that you may have added (or may not) are the extends in Java, just like the inheritance of MonoBehaviour in Unity’s C# classes. Let’s fill them up from these three Gists WorldExtension, ForwardHandler, HaltHandler. Their code is quite simple. The WorldExtension class adds a listener for the command forward. When we send the forward command from the client, this part of code will instantly search for the ForwardHandler class and call the code in the function handleClientRequest. The ForwardHandler class will issue an updateSpeed command with an updated speed parameter. Same goes for HaltHandler which makes the speed parameter zero and returns it.

Our code is ready. Now we need to export it for use. Chose Export from the File menu, and from the export destination select the Java>JAR file and press Next. Tick the WorldExtension, and in the export destination select SMARTFOXSERVER_INSTALLATION_DIRECTORYSmartFoxServer_2XSFS2XextensionsWorldExtensionWorldExtension.jar. I have added some folders which don’t exist here so create them respectively with the same naming convention.

It’s time for test again. If a SmartFox instance is running close it and open it again to scan our new extension. Log in again to the admin panel, and from the left head into Zone Configurator. In the left column that appeared click on the green plus button at the bottom, to create a new Zone for our server. In the Zone name, type in the name of the Extension we created in Java, WorldExtension. then head to the Zone Extension tab, and in the Name select the name of our extension. The Main class selection should fill itself automatically to indicate WorldExtension. If not then point to it. Finally click submit. We should see our new extension in the Zones column. Select it and press the button which indicates the start.

Send Commands from Unity3D

Running our project now should yield a succesfull log in! Hooray!! We can now send and receive commands, so let’s expand our project a bit to try it out. Create a C# script with the name Mover and write this code. Then add to Unity a 3D Object Cube (or anything else visible). Add as a component the Mover script. Now run the code. By pressing the W, Unity sends the forward command to server and the server responds with the speed. By pressing Space, Unity sends the halt command to the server, and the server makes the speed zero and returns it for Unity. The cube should move and then stop as you press the buttons.

That’s it!

What to do next?

Although the example was very simple we can’t do much with this. However it is a base to go forward from here. Let me leave you with an excersise. Back in the Java project where we sent the command updateSpeed we only send it to one user. Can you change it to send it to all users connected in the zone?

Smartfoxserver

Also when more players connect to the server you need to know which gameobject belongs to which player. That’s easy! When you send back commands from the server add as a parameter the player’s id, so the clients always know which players object should be moving.

The rest I leave to you (or not, I might create a part 2 with a more practical example, and depth to SmartFoxServer. What do you think? ) Hope you enjoyed it and if you have any questions don’t hesitate to ask.

  • For service providers
    • test
  • Products
    • Cloud Options
    • Services
  • Functionality
    • Runtimes
    • Features
  • Pricing
    • test
  • Support
    • Resources
    • About Us
    • Get in Touch
  • Get Started
    • test

Mobile gaming is a growing phenomena that has exploded with the rapid propagation of smartphones and tablets, in particular those running Apple iOS and Android.
In 2009 the smartphone game sales on those two platforms amounted to 19% of the market. Two years later it was 58% and it’s now leading the apps market, with expected revenues in excess of $8 million for 2013 and twice as much for 2014.
Every day new developers are joining the community of mobile gaming. We have prepared a simple tutorial that will demonstrate how easy it is to get started with Jelastic and SmartFoxServer 2X.
SmartFoxServer 2X is a comprehensive platform for rapid development of multiplayer game s and applications, supporting Adobe Flash, HTML5, Android, Unity3D, iOS, Java, C++ and more. SmartFoxServer 2X comes for free with a 100 CCU (concurrent users) license, 100% of the features and no time limitations.
Thanks to its simplicity of use, versatility and performance, it currently powers hundreds of projects all over the world, from simple turn-based games to massive virtual worlds and real-time action games.
In this post we will show how to rapidly setup a Jelastic environment and deploy SmartFoxServer for testing and production. The whole operation takes no longer than 5 minutes.

Create environment

1. Log into Jelastic Manager and click on Create environment button.
2. Select the Expert Environment topology, click on the VDS button and specify the cloudlet limit for your node. After that type the name of your environment and click Create.

3. After you environment is successfully created establish SSH connection using any SSH client suitable for your OS (MacOS, Linux, BSD or Windows) or Jelastic web-based client.

Install server

1. Download SmartFoxServer community addition for Linux x64.

2. Unpackage the archive you've just downloaded.

Smartfoxserver Tutorial

Configure the server’s public IP address. In the <unpacked-folder>/SFS2X/config directory open the server.xml file and edit the following line by replacing 127.0.0.1 with the real address of your Jelastic VDS.

4. Navigate to /SFS2X/ directory and enter the next command:

Now you can navigate to your SmartFoxServer in a browser using the public IP address of your VDS. For example: http://10.11.12.13:8080. The default credentials for the administrator are: sfsadmin / sfsadmin.

Success! You have completed the process.Ideas

Performance test

The engineers at SmartFoxServer helped Jelastic testing the overall performance of the proposed solution. We used a custom built tool that allows to spawn thousands of clients and generate huge traffic towards the server.
For our simple stress test we set up a cluster of 3 client machines (1 master + 2 slaves) to overload a single SmartFoxServer 2X instance with traffic. Every client runs in its own Jelastic VDS, configured with 32 cloudlets and generating 8333 clients each.
The following are the essential statistics:

  • 25000 total concurrent clients
  • Approximately 5000 Rooms are created
  • Login phase = 30 clients/sec joining the server
  • 6250 messages/sec going to the server
  • 31250 messages/sec going out of the server (this is because each messages is broadcast to 5 users in each Room)
  • The generated network traffic is approximately 8Mb/s IN, and 32Mb/s OUT
  • The whole test uses less than 15% of the CPU and approximately 1.2GB of RAM on the SmartFox instance.

The test was run using the SmartFoxServer’s default configuration for three days, setting the JVM maximum memory at 2GB.
With 25K CCU consuming less than 15% of the computing resources it is immediately clear the massive scalability potential of the SmartFox and Jelastic combination. Paired with the natural horizontal scalability of the cloud, this solution can satisfy projects of all sizes and easily grow with its audience.

Smartfoxserver

Finally, with the ability of Jelastic to dynamically allocate resources on the fly, according to the minimum and maximum configured by the user, the solution can satisfy the technical requirements and budgets of every game developer.
If you’re interested in learning more about large SmartFoxServer deployments and relative architectures you can consult these white papers.

Testing a mobile game

SmartFoxServer 2X comes with a large pool of example games for all major supported platforms that can be tested and studied out of the box.
In this white paper we will use the Android version of the Tic-Tac-Toe to get started with SmartFoxServer 2X.
1. Start by downloading the Android example pack.
2. Extract the files from the package you've just downloaded and install the .apk on your Android device (Tris/deploy/client/ in our case). You will need to have Android SDK Tools installed.

3. Copy the tris/ folder from the Tris/deploy/extensions/ folder to your SFS2X installation folder, under SFS2X/extensions/
In order to start the game on the client launch the app and change the connection details of your SmartFoxServer using its public IP address.

Conclusions

The multiplayer aspect in mobile game plays a central role in improving the longevity and popularity of your products, allowing users to enjoy live interaction with friends and other players.
For more information about SmartFoxServer:

Smartfoxserverpro

Smartfoxserver Hosting

For more information about Jelastic: