# Class: StompServerHandler

## vertx-stomp-js/stomp_server_handler~ StompServerHandler

#### new StompServerHandler()

STOMP server handler implements the behavior of the STOMP server when a specific event occurs. For instance, if let customize the behavior when specific STOMP frames arrives or when a connection is closed. This class has been designed to let you customize the server behavior. The default implementation is compliant with the STOMP specification. In this default implementation, not acknowledge frames are dropped.

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 42

### Methods

#### abortHandler(handler) → {StompServerHandler}

Configures the action to execute when a `ABORT` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 217

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### ackHandler(handler) → {StompServerHandler}

Configures the action to execute when a `ACK` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 268

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### authProvider(handler) → {StompServerHandler}

Configures the to be used to authenticate the user.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | AuthProvider | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 341

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### beginHandler(handler) → {StompServerHandler}

Configures the action to execute when a `BEGIN` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 234

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### bridge(options) → {StompServerHandler}

Configures the STOMP server to act as a bridge with the Vert.x event bus.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | the configuration options

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 506

##### Returns:

the current StompServerHandler.

Type
  StompServerHandler

#### closeHandler(handler) → {StompServerHandler}

Configures the action to execute when a connection with the client is closed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 169

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### commitHandler(handler) → {StompServerHandler}

Configures the action to execute when a `COMMIT` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 200

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### connectHandler(handler) → {StompServerHandler}

Configures the action to execute when a `CONNECT` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 84

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### destinationFactory(factory) → {StompServerHandler}

Configures the DestinationFactory used to create Destination objects.

##### Parameters:

Name | Type | Description
--- | --- | ---
`factory` | DestinationFactory | the factory

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 491

##### Returns:

the current StompServerHandler.

Type
  StompServerHandler

#### disconnectHandler(handler) → {StompServerHandler}

Configures the action to execute when a `DISCONNECT` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 251

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### getDestination(destination) → {Destination}

Gets the destination with the given name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`destination` | string | the destination

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 369

##### Returns:

the Destination, `null` if not existing.

Type
  Destination

#### getDestinations() → {Array.<Destination>}

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 355

##### Returns:

the list of destination managed by the STOMP server. Don't forget the STOMP interprets destination as opaque Strings.

Type
  Array.<Destination>

#### getOrCreateDestination(destination) → {Destination}

Gets a Destination object if existing, or create a new one. The creation is delegated to the DestinationFactory.

##### Parameters:

Name | Type | Description
--- | --- | ---
`destination` | string | the destination

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 477

##### Returns:

the Destination instance, may have been created.

Type
  Destination

#### getUserBySession(session) → {User}

Provides for authorization matches on a destination level, this will return the User created by the .

##### Parameters:

Name | Type | Description
--- | --- | ---
`session` | string | session ID for the server connection.

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 327

##### Returns:

null if not authenticated.

Type
  User

#### handle(arg0)

##### Parameters:

Name | Type | Description
--- | --- | ---
`arg0` | ServerFrame |

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 52

#### nackHandler(handler) → {StompServerHandler}

Configures the action to execute when a `NACK` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 285

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### onAck(connection, subscribe, messages) → {StompServerHandler}

Method called by single message (client-individual policy) or a set of message (client policy) are acknowledged. Implementations must call the handler configured using StompServerHandler#onAckHandler.

##### Parameters:

Name | Type | Description
--- | --- | ---
`connection` | StompServerConnection | the connection
`subscribe` | Object | the `SUBSCRIBE` frame
`messages` | Array.<Object> | the acknowledge messages

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 386

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### onAckHandler(handler) → {StompServerHandler}

Configures the action to execute when messages are acknowledged.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 421

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### onAuthenticationRequest(connection, login, passcode, handler) → {StompServerHandler}

Called when the client connects to a server requiring authentication. It invokes the configured using StompServerHandler#authProvider.

##### Parameters:

Name | Type | Description
--- | --- | ---
`connection` | StompServerConnection | server connection that contains session ID
`login` | string | the login
`passcode` | string | the password
`handler` | function | handler receiving the authentication result

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 306

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### onClose(connection)

Called when the connection is closed. This method executes a default behavior and must calls the configured StompServerHandler#closeHandler if any.

##### Parameters:

Name | Type | Description
--- | --- | ---
`connection` | StompServerConnection | the connection

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 186

#### onNack(connection, subscribe, messages) → {StompServerHandler}

Method called by single message (client-individual policy) or a set of message (client policy) are not acknowledged. Not acknowledgment can result from a `NACK` frame or from a timeout (no `ACK` frame received in a given time. Implementations must call the handler configured using StompServerHandler#onNackHandler.

##### Parameters:

Name | Type | Description
--- | --- | ---
`connection` | StompServerConnection | the connection
`subscribe` | Object | the `SUBSCRIBE` frame
`messages` | Array.<Object> | the acknowledge messages

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 406

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### onNackHandler(handler) → {StompServerHandler}

Configures the action to execute when messages are not acknowledged.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 438

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### pingHandler(handler) → {StompServerHandler}

Allows customizing the action to do when the server needs to send a `PING` to the client. By default it send a frame containing `EOL` (specification). However, you can customize this and send another frame. However, be aware that this may requires a custom client.

The handler will only be called if the connection supports heartbeats.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the action to execute when a `PING` needs to be sent.

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 459

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### receivedFrameHandler(handler) → {StompServerHandler}

Configures a handler that get notified when a STOMP frame is received by the server. This handler can be used for logging, debugging or ad-hoc behavior.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 67

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### sendHandler(handler) → {StompServerHandler}

Configures the action to execute when a `SEND` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 152

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### stompHandler(handler) → {StompServerHandler}

Configures the action to execute when a `STOMP` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 101

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### subscribeHandler(handler) → {StompServerHandler}

Configures the action to execute when a `SUBSCRIBE` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 118

##### Returns:

the current StompServerHandler

Type
  StompServerHandler

#### unsubscribeHandler(handler) → {StompServerHandler}

Configures the action to execute when a `UNSUBSCRIBE` frame is received.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function | the handler

Source:
  - vertx-stomp-js/stomp_server_handler.js, line 135

##### Returns:

the current StompServerHandler

Type
  StompServerHandler