This is the homepage of the SmartFoxServer 2X JavaScript server API documentation (JSDoc).

The server API provides all the global methods and classes to write the server side Extensions for SmartFoxServer 2X using the JavaScript language, as described in the official documentation.


SmartFoxServer 2X is a Java application running in the JVM (Java Virtual Machine), so any server side JavaScript code is also running in the JVM. More specifically JavaScript runs in the Nashorn JavaScript engine, a powerful Ecmascript 5 interpreter/compiler provided with JDK 8 and higher. This means that the server side code interacts with the SmartFoxServer 2X Java API and the Java Runtime: in fact many of the objects provided by the server JavaScript API are actually Java objects.

This is important because in the documentation you will find references to objects and classes that come from the "top level" API, in other words from Java. See the Conventions paragraph below.

From the javaScript point of view, all methods, classes and other API objects listed in this JSDoc are directly available in the global scope.

Documentation structure

The API documentation is divided into the following sections:

  • Namespaces

    Contains all the objects which provide factory methods to generate instances of specific classes.

  • Classes

    Contains the classes you will work with during the Extension development. The main classes to interact with SmartFoxServer and the connected clients are: SFSApi, GameApi, BuddyApi and MMOApi.

  • Global

    Contains the methods to register client request handlers and server event listeners, and more helper methods to access the Extension context (parent Zone or Room, etc). It also contains all the enum members which provide fixed values for specific operations.

The best starting point to learn the API are the global methods and the SFSApi class.


The following conventions are used throughout the API JSDoc:

  • All the native JavaScript classes (for example SFSApi) are fully documented.

  • All the Java classes that you can instantiate directly (for example new SFSObject()) and all the enums (for example BanMode.BY_ADDRESS) show a large icon at the top of the class description. Also, their members are not documented and you should refer to the Java server API documentation (a direct link to the related object is always provided).

  • All the classes you can get an instance of (by means of specific methods or events), but never instantiate directly (for example SFSRoom, returned by the getParentRoom() global method), are not documented and a link to the Java server API documentation is provided, preceded by a small icon.