Class WebSocketTransport
- java.lang.Object
-
- jadex.platform.service.message.websockettransport.WebSocketTransport
-
- All Implemented Interfaces:
ITransport<IWebSocketConnection>
public class WebSocketTransport extends java.lang.Object implements ITransport<IWebSocketConnection>
Transport implementing communication using web sockets.
-
-
Field Summary
Fields Modifier and Type Field Description protected WebSocketTransportAgenthandlerConnection handler.protected static intPRIORITYprotected WebSocketServerserverThe server for incoming connections.
-
Constructor Summary
Constructors Constructor Description WebSocketTransport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseConnection(IWebSocketConnection con)Perform close operations on a connection.IFuture<IWebSocketConnection>createConnection(java.lang.String address, IComponentIdentifier target)Create a connection to a given address.java.lang.StringgetProtocolName()Get the protocol name.voidinit(ITransportHandler<IWebSocketConnection> handler)Initialize the transport.IFuture<java.lang.Integer>openPort(int port)Open a port to accept connections.IFuture<java.lang.Integer>sendMessage(IWebSocketConnection con, byte[] header, byte[] body)Send bytes using the given connection.voidshutdown()Shutdown and free all resources.
-
-
-
Field Detail
-
PRIORITY
protected static final int PRIORITY
- See Also:
- Constant Field Values
-
handler
protected WebSocketTransportAgent handler
Connection handler.
-
server
protected WebSocketServer server
The server for incoming connections.
-
-
Method Detail
-
init
public void init(ITransportHandler<IWebSocketConnection> handler)
Initialize the transport. To be called once, before any other method.- Specified by:
initin interfaceITransport<IWebSocketConnection>- Parameters:
handler- The transport handler with callback methods.
-
shutdown
public void shutdown()
Shutdown and free all resources. To be called once, as last method.- Specified by:
shutdownin interfaceITransport<IWebSocketConnection>
-
getProtocolName
public java.lang.String getProtocolName()
Get the protocol name.- Specified by:
getProtocolNamein interfaceITransport<IWebSocketConnection>
-
openPort
public IFuture<java.lang.Integer> openPort(int port)
Open a port to accept connections.- Specified by:
openPortin interfaceITransport<IWebSocketConnection>- Parameters:
port- The (positive) port or 0 for any port.- Returns:
- A future holding the actual port, once the server is running.
-
createConnection
public IFuture<IWebSocketConnection> createConnection(java.lang.String address, IComponentIdentifier target)
Create a connection to a given address.- Specified by:
createConnectionin interfaceITransport<IWebSocketConnection>- Parameters:
address- The target platform's address.target- The target identifier to maybe perform authentication of the connection.- Returns:
- A future containing the connection when succeeded.
-
closeConnection
public void closeConnection(IWebSocketConnection con)
Perform close operations on a connection. Potentially cleans up key attachments as well.- Specified by:
closeConnectionin interfaceITransport<IWebSocketConnection>
-
sendMessage
public IFuture<java.lang.Integer> sendMessage(IWebSocketConnection con, byte[] header, byte[] body)
Send bytes using the given connection.- Specified by:
sendMessagein interfaceITransport<IWebSocketConnection>- Parameters:
sc- The connection.header- The message header.body- The message body.- Returns:
- A future indicating success.
-
-