Fluent builder for one app-defined websocket data type, configuring its connect, disconnect and message handler functions and whether it is restricted to admin domains. Started from ControllerMappingList.websocketController() and finished with build(), which constructs and registers the resulting RepoAppWebsocketMapping.
Group: Builders
Methods
type(String type)
Returns: WebsocketMappingBuilder
Sets the data type this websocket mapping is registered under, used to group and look up sockets of this kind.
| Parameter | Description |
|---|---|
type | the mapping's data type |
onConnected(Object function)
Returns: WebsocketMappingBuilder
Sets the function called when a new socket connection of this type is made. A Nashorn function is wrapped so it can be invoked like any other script function.
| Parameter | Description |
|---|---|
function | the function to call when a socket connects |
onDisconnected(Object function)
Returns: WebsocketMappingBuilder
Sets the function called when a socket of this type disconnects. A Nashorn function is wrapped so it can be invoked like any other script function.
| Parameter | Description |
|---|---|
function | the function to call when a socket disconnects |
onMessage(Object function)
Returns: WebsocketMappingBuilder
Sets the function called when a socket of this type sends a message to the server. A Nashorn function is wrapped so it can be invoked like any other script function.
| Parameter | Description |
|---|---|
function | the function to call when a message is received |
adminOnly(boolean adminOnly)
Returns: WebsocketMappingBuilder
Sets whether this websocket type is available on admin domains only.
| Parameter | Description |
|---|---|
adminOnly | true to restrict this socket type to admin domains |
build()
Returns: RepoAppWebsocketMapping
Finishes this builder, constructing a RepoAppWebsocketMapping from the configured values and, if the platform's engine initialisation has not yet completed, registering it so incoming websocket connections of this type can be dispatched to it.