From the course: WebSocket Programming with Java EE

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Programmatic methodology

Programmatic methodology

From the course: WebSocket Programming with Java EE

Start my 1-month free trial

Programmatic methodology

- [Narrator] The interface-driven programming model provides an imperative way to define the endpoints and manage web socket lifecycles. When developing an endpoint, you can choose the methodology that suits you best. But let's turn our attention to the programmatic style. The programmatic method represents an endpoint by instances of the Endpoint class. In this code snippet, you can see that the Server Endpoint class extends the abstract class Endpoint. The only method that must be implemented is on Open, in which message-handling logic is written for the three message types: text, binary, and pong. Here is an example of how to add a text-based message handler. Now two other live cell methods can be overwritten: onError, and onClose. All the endpoints written using the programmatic methodology must be resident in an application configuration class that implements the ServerApplicationConfig interface. The method getEndpointConfigs must be implemented with logic that registers the URI…

Contents