Errai 3.0.1-SNAPSHOT

org.jboss.errai.bus.client.framework.transports
Class WebsocketHandler

java.lang.Object
  extended by org.jboss.errai.bus.client.framework.transports.WebsocketHandler
All Implemented Interfaces:
TransportHandler, TransportStatistics

public class WebsocketHandler
extends Object
implements TransportHandler, TransportStatistics

Author:
Mike Brock

Field Summary
 
Fields inherited from interface org.jboss.errai.bus.client.framework.transports.TransportHandler
EXTRA_URI_PARMS_RESOURCE, UNSUPPORTED_MESSAGE_NO_CLIENT_SUPPORT, UNSUPPORTED_MESSAGE_NO_SERVER_SUPPORT
 
Constructor Summary
WebsocketHandler(ClientMessageBusImpl messageBus)
           
 
Method Summary
 void attachWebSocketChannel(Object o)
           
 Object attemptWebSocketConnect(String websocketAddr)
           
 void close()
          Permanently closes this transport handler.
 void configure(Message capabilitiesMessage)
          Called to configure the transport.
 void disconnectSocket(Object channel)
           
 long getConnectedTime()
           
 long getLastTransmissionTime()
           
 int getMeasuredLatency()
           
 int getMessagesReceived()
           
 int getMessagesSent()
           
 int getPendingMessages()
           
 String getRxEndpoint()
           
 TransportStatistics getStatistics()
          Returns the TransportStatistics instance.
 String getTransportDescription()
           
 String getTxEndpoint()
           
 String getUnsupportedDescription()
           
 void handleProtocolExtension(Message message)
          Allows extension to the standard ErraiBus Protocol by optionally handling any unknown protocol verbs from the wire.
static boolean isConnected(Object socket)
           
 boolean isFullDuplex()
           
 boolean isUsable()
          Indicates whether the transport is usable.
static boolean isWebSocketSupported()
           
 void start()
          Called to start the transport.
 Collection<Message> stop(boolean stopAllCurrentRequests)
          Called to stop the transport.
 String toString()
           
 void transmit(List<Message> txMessages)
          Transmits the specified list of Message to the remote bus over the transport.
 boolean transmitToSocket(Object socket, String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebsocketHandler

public WebsocketHandler(ClientMessageBusImpl messageBus)
Method Detail

configure

public void configure(Message capabilitiesMessage)
Description copied from interface: TransportHandler
Called to configure the transport. The Message instance passed to the handler, is the initial response message from the server during the ErraiBus protocol handshake, which contains the capabilities data for the remote bus.

Specified by:
configure in interface TransportHandler
Parameters:
capabilitiesMessage - the capabilities message from the message bus on handshake.

start

public void start()
Description copied from interface: TransportHandler
Called to start the transport.

Specified by:
start in interface TransportHandler

transmit

public void transmit(List<Message> txMessages)
Description copied from interface: TransportHandler
Transmits the specified list of Message to the remote bus over the transport.

Specified by:
transmit in interface TransportHandler
Parameters:
txMessages - a list of Message to be transmitted.

handleProtocolExtension

public void handleProtocolExtension(Message message)
Description copied from interface: TransportHandler
Allows extension to the standard ErraiBus Protocol by optionally handling any unknown protocol verbs from the wire.

Specified by:
handleProtocolExtension in interface TransportHandler

stop

public Collection<Message> stop(boolean stopAllCurrentRequests)
Description copied from interface: TransportHandler
Called to stop the transport.

Specified by:
stop in interface TransportHandler
Parameters:
stopAllCurrentRequests - specifying true will cause any in-flight messages which have not returned to be immediately cancelled.
Returns:
a list of messages which were not delivered before the transport was stopped.

isUsable

public boolean isUsable()
Description copied from interface: TransportHandler
Indicates whether the transport is usable. This method is called during transport switching by the bus to determine which transport to use. The first usable transport is chosen and started.

Specified by:
isUsable in interface TransportHandler
Returns:
true if the handler is usable.

attachWebSocketChannel

public void attachWebSocketChannel(Object o)

toString

public String toString()
Overrides:
toString in class Object

disconnectSocket

public void disconnectSocket(Object channel)

isWebSocketSupported

public static boolean isWebSocketSupported()

attemptWebSocketConnect

public Object attemptWebSocketConnect(String websocketAddr)

transmitToSocket

public boolean transmitToSocket(Object socket,
                                String text)

isConnected

public static boolean isConnected(Object socket)

getStatistics

public TransportStatistics getStatistics()
Description copied from interface: TransportHandler
Returns the TransportStatistics instance.

Specified by:
getStatistics in interface TransportHandler
Returns:

getTransportDescription

public String getTransportDescription()
Specified by:
getTransportDescription in interface TransportStatistics

getUnsupportedDescription

public String getUnsupportedDescription()
Specified by:
getUnsupportedDescription in interface TransportStatistics

getMessagesSent

public int getMessagesSent()
Specified by:
getMessagesSent in interface TransportStatistics

getMessagesReceived

public int getMessagesReceived()
Specified by:
getMessagesReceived in interface TransportStatistics

getConnectedTime

public long getConnectedTime()
Specified by:
getConnectedTime in interface TransportStatistics

getLastTransmissionTime

public long getLastTransmissionTime()
Specified by:
getLastTransmissionTime in interface TransportStatistics

getMeasuredLatency

public int getMeasuredLatency()
Specified by:
getMeasuredLatency in interface TransportStatistics

isFullDuplex

public boolean isFullDuplex()
Specified by:
isFullDuplex in interface TransportStatistics

getRxEndpoint

public String getRxEndpoint()
Specified by:
getRxEndpoint in interface TransportStatistics

getTxEndpoint

public String getTxEndpoint()
Specified by:
getTxEndpoint in interface TransportStatistics

getPendingMessages

public int getPendingMessages()
Specified by:
getPendingMessages in interface TransportStatistics

close

public void close()
Description copied from interface: TransportHandler
Permanently closes this transport handler. Once closed, a TransportHandler cannot be used again. It is imperative that a TransportHandler is closed when it is no longer needed; failing to do so may leak resources and lead to client bus malfunctions.

Specified by:
close in interface TransportHandler

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.