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:

Methods

abortHandler(handler) → {StompServerHandler}

Configures the action to execute when a ABORT frame is received.
Parameters:
Name Type Description
handler function the handler
Source:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
Returns:
the Destination, null if not existing.
Type
Destination

getDestinations() → {Array.<Destination>}

Source:
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:
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:
Returns:
null if not authenticated.
Type
User

handle(arg0)

Parameters:
Name Type Description
arg0 ServerFrame
Source:

nackHandler(handler) → {StompServerHandler}

Configures the action to execute when a NACK frame is received.
Parameters:
Name Type Description
handler function the handler
Source:
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:
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:
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:
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:

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:
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:
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:
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:
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:
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:
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:
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:
Returns:
the current StompServerHandler
Type
StompServerHandler