• Examples (iOS)
• Examples (Java/Android)
• Examples (C++)
Server API Documentation

 

» Websocket migration, release 2.13+

A number of different things have changed for websockets with the release of SmartFoxServer 2.13:

Please make sure to follow this brief guide if you have a websocket-based project (JavaScript or Unity WebGL) running on previous versions of SmartFoxServer 2X.

» Websocket ports

Starting from v2.13, SmartFoxServer uses the Jetty Web Server to run all HTTP-related services, including websockets. This means that you no longer have to setup different TCP ports for HTTP/HTTPS services and WS/WSS services. Instead all services now run on two main TCP ports, which by default are:

If you want to change these ports you can do so via the AdminTool > Server Settings > Web Server tab.

Please note: out of the box, the websocket services are not active. You can turn them on via the "Enable WS/WSS" switch shown in the image above, choose the type of protocol (default = binary; read below) and restart the server.

» Client API and protocol

Before release v2.13, the JavaScript and C# (Unity WebGL only!) APIs used a JSON-based protocol for websocket communication. With SFS2X 2.13 and later we offer new, improved APIs which use the efficient SFS2X binary/compressed protocol that is implemented in all other supported languages.

By default the server uses the new protocol but you can still revert to the previous version by switching off the "Use WS binary protocol" option from the picture above.

For all new HTML5 / Unity WebGL projects we highly recommend to start working with the new binary protocol API as this is more compact and efficient. Also this is the API we will focus on for the incoming future.

For older projects based on the previous API we will keep maintaining the code in terms of bug fixes, but we won't add any new features. With time we would encourage previous projects to migrate, if possible, to the new API.

ยป Compatibility notes for older projects

If you're going to upgrade to SFS2X v2.13 or later and run a websocket project developed with v2.12 or previous (in other words with the older JavaScript or C# API), we recommend to follow these simple steps:

If you have any questions or problems with websocket settings you can reach us through our support forum.