# Class: StompClientConnection

## vertx-stomp-js/stomp_client_connection~ StompClientConnection

#### new StompClientConnection()

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 30

### Methods

#### abort(id, headers, receiptHandler) → {StompClientConnection}

Aborts a transaction.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | string | the transaction id, must not be `null`
`headers` | Array.<string> | additional headers to send to the server. The `transaction` header is replaced by the value passed in the @{code id} parameter
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the transaction cancellation has been processed by the server. The handler receives the sent frame (`ABORT`).

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 343

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### ack(id, txId, receiptHandler) → {StompClientConnection}

Sends an acknowledgement for the given frame. It means that the frame has been handled and processed by the client. The sent acknowledgement is part of the transaction identified by the given id.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | string | the message id of the message to acknowledge
`txId` | string | the transaction id
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the acknowledgment has been processed by the server. The handler receives the sent frame (`ACK`).

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 404

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### beginTX(id, headers, receiptHandler) → {StompClientConnection}

Begins a transaction.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | string | the transaction id, must not be `null`
`headers` | Array.<string> | additional headers to send to the server. The `transaction` header is replaced by the value passed in the @{code id} parameter
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the transaction begin has been processed by the server. The handler receives the sent frame (`BEGIN`).

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 283

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### close()

Closes the connection without sending the `DISCONNECT` frame.

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 69

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

Sets a handler notified when the STOMP connection is closed.

##### Parameters:

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

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 227

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### commit(id, headers, receiptHandler) → {StompClientConnection}

Commits a transaction.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | string | the transaction id, must not be `null`
`headers` | Array.<string> | additional headers to send to the server. The `transaction` header is replaced by the value passed in the @{code id} parameter
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the transaction commit has been processed by the server. The handler receives the sent frame (`COMMIT`).

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 313

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### connectionDroppedHandler(handler) → {StompClientConnection}

Sets a handler notified when the server does not respond to a `ping` request in time. In other words, this handler is invoked when the heartbeat has detected a connection failure with the server. The handler can decide to reconnect to the server.

##### Parameters:

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

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 246

##### Returns:

the current StompClientConnection receiving the dropped connection.

Type
  StompClientConnection

#### disconnect(frame, receiptHandler) → {StompClientConnection}

Disconnects the client. Unlike the StompClientConnection#close method, this method send the `DISCONNECT` frame to the server. This method lets you customize the `DISCONNECT` frame.

##### Parameters:

Name | Type | Description
--- | --- | ---
`frame` | Object | the `DISCONNECT` frame.
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the disconnection has been processed by the server. The handler receives the sent frame (`DISCONNECT`).

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 373

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### errorHandler(handler) → {StompClientConnection}

Sets a handler notified when an `ERROR` frame is received by the client. The handler receives the `ERROR` frame and a reference on the StompClientConnection.

##### Parameters:

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

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 210

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### nack(id, txId, receiptHandler) → {StompClientConnection}

Sends a non-acknowledgement for the given frame. It means that the frame has not been handled by the client. The sent non-acknowledgement is part of the transaction identified by the given id.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | string | the message id of the message to acknowledge
`txId` | string | the transaction id
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the non-acknowledgment has been processed by the server. The handler receives the sent frame (`NACK`).

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 435

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

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

Sets a handler that let customize the behavior when a ping needs to be sent to the server. Be aware that changing the default behavior may break the compliance with the STOMP specification.

##### Parameters:

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

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 264

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

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

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

Unlike StompClient#receivedFrameHandler, the given handler won't receive the `CONNECTED` frame. If a received frame handler is set on the StompClient, it will be used by all clients connection, so calling this method is useless, except if you want to use a different handler.

##### Parameters:

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

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 467

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### send(destination, headers, body, receiptHandler) → {StompClientConnection}

Sends a `SEND` frame to the server to the given destination.

##### Parameters:

Name | Type | Description
--- | --- | ---
`destination` | string | the destination, must not be `null`
`headers` | Array.<string> | the header. The `destination` header is replaced by the value given to the `destination` parameter
`body` | Buffer | the body, may be `null`
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the sent frame has been received. The handler receives the sent frame.

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 100

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### server() → {string}

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 83

##### Returns:

- the server name.
- Type
    string

#### session() → {string}

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

##### Returns:

- the session id.
- Type
    string

#### subscribe(destination, headers, handler, receiptHandler) → {string}

Subscribes to the given destination.

##### Parameters:

Name | Type | Description
--- | --- | ---
`destination` | string | the destination, must not be `null`
`headers` | Array.<string> | the headers to configure the subscription. It may contain the `ack` header to configure the acknowledgment policy. If the given set of headers contains the `id` header, this value is used as subscription id.
`handler` | function | the handler invoked when a message is received on the given destination. Must not be `null`.
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the subscription has been received. The handler receives the sent frame (`SUBSCRIBE`).

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 147

##### Returns:

the subscription id, which can either be the destination or the id set in the headers.

Type
  string

#### unsubscribe(destination, headers, receiptHandler) → {StompClientConnection}

Un-subscribes from the given destination. This method computes the subscription id as follows. If the given headers contains the `id` header, the header value is used. Otherwise the destination is used.

##### Parameters:

Name | Type | Description
--- | --- | ---
`destination` | string | the destination
`headers` | Array.<string> | the headers
`receiptHandler` | function | the handler invoked when the `RECEIPT` frame associated with the un-subscription has been received. The handler receives the sent frame (`UNSUBSCRIBE`).

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 182

##### Returns:

the current StompClientConnection

Type
  StompClientConnection

#### version() → {string}

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 56

##### Returns:

- the STOMP protocol version negotiated with the server.
- Type
    string

#### writingFrameHandler(handler) → {StompClientConnection}

Configures a handler notified when a frame is going to be written on the wire. This handler can be used from logging, debugging. The handler can modify the received frame. If a writing frame handler is set on the StompClient, it will be used by all clients connection, so calling this method is useless, except if you want to use a different handler.

##### Parameters:

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

Source:
  - vertx-stomp-js/stomp_client_connection.js, line 488

##### Returns:

the current StompClientConnection

Type
  StompClientConnection