tuweni / org.apache.tuweni.hobbits / HobbitsTransport

HobbitsTransport

class HobbitsTransport : CoroutineScope (source)

Hobbits is a peer-to-peer transport stack specified at https://www.github.com/deltap2p/hobbits.

This class works as a transport mechanism that can leverage a variety of network transport protocols, such as TCP, HTTP, UDP and Web sockets.

It can be used to contact other Hobbits endpoints, or to expose endpoints to the network.

Parameters

vertx - Vert.x instance

incompleteMessageHandler - a handler to manage incomplete or invalid messages

coroutineContext - the co-routine context for the transport

Constructors

<init>

Hobbits is a peer-to-peer transport stack specified at https://www.github.com/deltap2p/hobbits.

HobbitsTransport(vertx: Vertx, incompleteMessageHandler: (Bytes) -> Unit = {}, coroutineContext: CoroutineContext = Dispatchers.Default)

Properties

coroutineContext

the co-routine context for the transport

val coroutineContext: CoroutineContext

Functions

createHTTPEndpoint

Creates a new endpoint over http.

fun createHTTPEndpoint(id: String = "default", networkInterface: String = "0.0.0.0", port: Int = 9337, requestURI: String? = null, tls: Boolean = false, handler: (Message) -> Unit, portUpdateListener: (Int) -> Unit = {}): Unit

createTCPEndpoint

Creates a new endpoint over tcp persistent connections.

fun createTCPEndpoint(id: String = "default", networkInterface: String = "0.0.0.0", port: Int = 9237, tls: Boolean = false, handler: (Message) -> Unit, portUpdateListener: (Int) -> Unit = {}): Unit

createUDPEndpoint

Creates a new endpoint over UDP connections.

fun createUDPEndpoint(id: String = "default", networkInterface: String = "0.0.0.0", port: Int = 9137, handler: (Message) -> Unit): Unit

createWSEndpoint

Creates a new endpoint over websocket connections.

fun createWSEndpoint(id: String = "default", networkInterface: String = "0.0.0.0", port: Int = 9037, requestURI: String? = null, tls: Boolean = false, handler: (Message) -> Unit, portUpdateListener: (Int) -> Unit = {}): Unit

exceptionHandler

Sets an exception handler that will be called whenever an exception occurs during transport.

fun exceptionHandler(handler: (Throwable) -> Unit): Unit

sendMessage

Sends a message using the transport specified.

suspend fun sendMessage(message: Message, transport: Transport, host: String, port: Int, requestURI: String = ""): Unit

start

Starts the hobbits transport.

suspend fun start(): Unit

stop

Stops the hobbits transport.

fun stop(): Unit