Continuing from a previous post about Singletons we are going to discuss a simple strategy to maintain application state across multiple Extension reloads. Before delving into the details, let’s first analyze the reasons why this may help. Continue reading
Author Archives: SmartFoxServer Team
The singleton solution
One of the questions that often gets asked in our support forums is something along the lines of “How do I create a singleton class where to store data that is global among all Extensions?”
This is a relatively complex subject in SmartFoxServer because each Extension is loaded in a separate Class Loader, thus making it more difficult to create a singleton that can be shared.
If you’re not entirely familiar with how Extension loading works you can consult this article for a quick overview. Part of these rules are essentially inherited from the Java Virtual Machine (JVM) architecture and, even if they might seem a bit convoluted, they help with reloading new code at runtime without stopping or restarting the server.
There is however a simple deployment trick that can be employed. Using the extensions/__lib__/ folder we can deploy a jar file with one or multiple classes that will be accessible from any Extension, even throughout multiple reloads.
In other words this will not change the way in which you deploy your Extension in SmartFoxServer 2X, however you will need to export the Singleton class(es) to a separate jar file that will be deployed to –> extensions/__lib__/
From a coding point of view nothing changes, which means that you don’t need to create a different project for your Singleton(s). You can keep them with your main Extension project and just deploy them differently, as described. Most Java IDEs will allow you to export a number of selected classes to a specific jar file, which can then be deployed as we have discussed.
Decoding DAU, MAU and CCU
In this article we will try to demystify several acronyms related to online traffic that are commonly found in the multiplayer/online lingo, but are usually not well understood.
Even without knowing anything about online gaming many of us are familiar with concepts such as “unique visits”, “daily visits” etc… which represent different metrics of online activity, typically in the context of a website traffic.
More recently, especially since the inception of social networking and online gaming, we have seen new acronyms being used such as DAU (daily active users), MAU (monthly active users) and CCU (concurrent users). But how exactly are these values calculated?, What do the represent? And how do they translate between each other? Continue reading
10 Years Promo continues
Given the large appreciation from our customers, we have decided to extend the amazing 20% discount on all our server products until the end of January 2015. Don’t miss it, visit our online shop!
AutoJoiner Extension
In this recipe we will see how we can create a simple Extension that automatically joins users in an available Room and creates more Rooms when the seats are all occupied. Continue reading
How to send an email from an Extension
Emails can be sent directly from your server side code in order to provide registration confirmations, updates or even debugging and stats reports.
In order to enable email sending you will need to setup the Emailer Service from the AdminTool: from theServerConfigurator choose the Emailer tab, turn on the service and set your SMTP parameters. Continue reading
How to schedule timed tasks in an Extension
Often times in the server-side game logic it is necessary to use timers for recurring events that are sent to the clients (e.g. the end of a turn time, npc actions, etc).
A quick solution to this problem is using the ScheduledThreadPoolExecutor class, provided in the JDK, which offers a convenient task executor backed by a pool of threads. SFS2X already runs its own instance of this Executor (wrapped in a class called TaskScheduler). Continue reading
How to debug your Extensions
You can easily attach a Remote Debugger to the server and enable your favorite Debugger for bug hunting in your Extensions.
SmartFoxServer 2X can be started with the sfs2x.bat (Windows) or sfs2x.sh (Linux/Unix/MacOSX) scripts. By adding some JVM switches to the launch script you can enable remote debugging. You can do it by following these steps: Continue reading
How to check the server logs
SFS2X provides detailed logging of all its activities. You can consult them at any time by checking the logs/folder. Additionally under the logs/boot/ folder you will find detailed logs of the boot phase. Continue reading
How to use the SmartFoxBits 2X
Together with SFS2X we provide the latest version of our SmartFoxBits components, which can save you a ton of time in setting up the application GUI if you are using the Adobe Flash platform to build your client.
The base SmartFoxBits pack contains five components:
- Connector: manages the connection/disconnection process (supporting the new reconnection system too)
- Login: handles the login process
- RoomList: manages the Rooms list, including the Groups feature (allowing to create multiple views of the list based on groups)
- UserList: manages the user list allowing private chat
- ChatBox: provides a basic chatting component
You can check all the details and read the documentation on the SmartFoxBits page.
