This example shows you how to build WebSockets server with the correct options for the
Autobahn WebSockets Protocol compliance tests. This example uses our
WebSocket Tools Library to implement the WebSocket protocol. The basic structure of the server is very similar to the
Binary WebSocket Echo Server example and you should go and read about that first and have a good understanding of how everything fits together. This document will only cover the differences between that example and this one.
This example requires the "WebSockets" licensing option of The Server Framework and it requires libraries that only ship with that option (see
here for licensing options). You can always download the latest version of this example from
here; and although you will need the correct libraries to be able to build it you can look at the example code and see how it works and perhaps get ideas from it. A compiled, unicode release, build of this example is available on request if you require it for performance analysis of the framework.
The Autobahn compliance tests require that a server behave in a specific way so that they can test compliance. Rather than complicating the other example servers just for the sake of passing the tests we decided to put together an example especially designed to pass the tests.
The diferences between this and the
Binary WebSocket Echo Server examples is quite slight...
-
We support both binary and text messages.
-
We echo entire messages using the accumulation and "large message API" techniques from the Binary WebSocket Echo Server example.
-
We don't fail the connection if we receive an unexpected Ping response.
-
We validate UTF-8 text messages within the protocol handler and fail the connection as soon as we notice invalid UTF-8 data in the message.