sfs3-api
v3.0.19-beta
Published
Official JavaScript client API for SmartFoxServer 3, the leading SDK to create large scale multiplayer games and MMOs
Maintainers
Readme

What is SmartFoxServer
SmartFoxServer is a comprehensive SDK for rapidly developing multiplayer games and applications using all the major web and mobile technologies like Godot, Unity, iOS, Android and, in particular, HTML5 / JavaScript.
SmartFoxServer comes with a rich set of features, an impressive documentation set, a large number of examples with their source code, powerful administration tools, a free Community Edition and a very active support forum.
Born in 2004 and evolving continuously since then, today SmartFoxServer 3 (aka SFS3) keeps expanding the core SmartFoxServer philosophy established by the previous editions, making our platform the leading middleware to create large scale multiplayer games, MMOs and virtual communities.
Thanks to its simplicity of use, versatility and performance, SmartFoxServer currently powers hundreds of projects all over the world, from small chats and turn-based games to massive virtual worlds and realtime games.
Please visit smartfoxserver.com to get started.
JavaScript Client API for SFS3
This npm package installs the latest version of the SmartFoxServer 3 Client API for JavaScript, enabling games and applications developed with this programming language to "speak" the SFS3 protocol and interact with the server very easily and securely.
RELEASE NOTES: https://www.smartfoxserver.com/download/releaseNotes/SFS3_API_JavaScript.txt
NOTE ON VERSIONING: the version number of this package mirrors the JavaScript API version number on the SmartFoxServer website. In case of changes to this readme document only, a letter will be added (for example 3.0.0-a).
Installation
To install the SFS3 Client API package for JavaScript, go to your project's folder in a terminal/console window and execute this command:
npm install sfs3-api --saveThis automatically adds the sfs3-api entry in the dependancies section of your project's package.json file.
Usage
In your project you can use a module bundler (we recommend webpack) and the standard JavaScript module syntax to access the API, like this:
import * as Sfs3 from "sfs3-api";You can then instantiate the API classes by means of the Sfs3 namespace (or any other name you entered in the import statement). The following example shows how to create an instance of the main SmartFox class, add a few listeners and establish a connection with SmartFoxServer.
let sfs = new Sfs3.SmartFox();
sfs.addEventListener(Sfs3.SFSEvent.CONNECTION, onConnection, this);
sfs.connect();
function onConnection(evtParams)
{
if (evtParams[Sfs3.EventParam.Success])
console.log("Connected to SmartFoxServer 3");
else
console.log("Connection failed. Is the server running at all?");
}As an alternative, you can import specific classes and avoid using the namespace, like this:
import { SmartFox, SFSEvent } from "sfs3-api";
let sfs = new SmartFox();
sfs.addEventListener(SFSEvent.CONNECTION, onConnection, this);
...Basic example
A complete, yet simple example showing how to setup your npm project and build it using webpack is available in the SmartFoxServer 3 documentation.
Other resources
- Full SmartFoxServer 3 documentation: https://docs3.smartfoxserver.com
- JavaScript client API documentation: https://docs3.smartfoxserver.com/client-api-setup/javascript-api-setup
- HTML5 tutorials and examples: https://docs3.smartfoxserver.com/examples/html5/intro
