Websockets
How to build Websocket APIs in Elements
Elements 3.0 offers Standards Compliant Websockets built in using the Jakarta Websocket API 2.1. Websockets are useful in creating high performance bi-directional communication between client and server code. Generally speaking, Websockets are considerably faster than HTTP requests for authoritative code and work well with practically all clients including Web, Unity3d, Unreal, .NET and many other connected services.
Steps to Defining a Websocket Element
To use the Jakarta RS in your own Element, you must perform the following steps:
Define the Element by annotating the
package-info
type in your code.Add all compiled classes and jars into the Element package structure.
Annotate each Websocket endpoint with the
ServerEndpoint
annotation.
Complete Example
The following example walks through the necessary files to define a simple Websocket echo server.
Step1: Define the Element
Step 2: Define the Element
Step 3: Ensure All Dependencies are Included
Last updated