hobbits / 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.

Constructors

<init>

HobbitsTransport(vertx: Vertx, coroutineContext: CoroutineContext = Dispatchers.Default)

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

Properties

coroutineContext

val coroutineContext: CoroutineContext

Functions

createHTTPEndpoint

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

Creates a new endpoint over http.

createTCPEndpoint

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

Creates a new endpoint over tcp persistent connections.

createUDPEndpoint

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

Creates a new endpoint over UDP connections.

createWSEndpoint

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

Creates a new endpoint over websocket connections.

exceptionHandler

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

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

sendMessage

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

Sends a message using the transport specified.

start

suspend fun start(): Unit

Starts the hobbits transport.

stop

fun stop(): Unit

Stops the hobbits transport.