• Examples (HTML5)
• Examples (iOS)
• Examples (Android)
• Examples (C++)
Server API Documentation

 

» HTML5 / JavaScript examples

In this section of the documentation we provide a series of tutorials on the HTML5 / JavaScript examples distributed as a specific package on the SmartFoxServer 2X download page.

Each tutorial analyzes a single example, describing its objectives, giving an insight into the SmartFoxServer features it wants to highlight and providing the direct link to download the source code, which includes all the assets required to run it (both client and — if needed — server side assets). Where necessary, code excerpts are provided in the tutorial itself, in order to better explain the approach that was followed to implement a specific feature. At the bottom of the tutorial, additional resources are linked if available.

The tutorials are ordered following the increasing complexity of the examples they refer to: we go from the simplest application we could think of, which just shows how to connect to SmartFoxServer, to some fully-featured games, both turn-based and realtime.

Unless otherwise noted inside the tutorials:

NOTE 1
All the examples make use of the latest version of the SmartFoxServer 2X JavaScript API available when they have been published. As the API evolve in time (bug fixes, new features), we strongly recommend that, after downloading an example, you overwrite the included API JS file (typically sfs2x-api-x.y.z.js in the source code's libs folder) with the one provided in the latest version available on our website.

NOTE 2
Under Internet Explorer 11, when running the examples by double clicking their html file, the browser may show an alert preventing the JavaScript code to be executed - you can allow the blocked content as it does no harm.
Due to local content loading, the Tris and Simple MMO World examples don't work properly if their html file is loaded in Internet Explorer 11 or Google Chrome by double clicking it. Both issues do not occur if the examples are deployed in the SFS2X internal web server.

Server setup

The examples require SmartFoxServer 2X v2.13 (or later) and the WebSocket (WS) communication to be enabled. By default this is disabled, so before running the examples make sure you activate the WS protocol in the AdminTool's Server Configurator module, under the Web server tab.
All other settings can be left unchanged, as the examples use the default port settings.

Time to click on the first example in the sidebar... enjoy the reading!