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.
incompleteMessageHandler
- a handler to manage incomplete or invalid messages
coroutineContext
- the co-routine context for the transport
HobbitsTransport(vertx: Vertx, incompleteMessageHandler: (Bytes) -> Unit = {}, coroutineContext: CoroutineContext = Dispatchers.Default)
Hobbits is a peer-to-peer transport stack specified at https://www.github.com/deltap2p/hobbits. |
val coroutineContext: CoroutineContext
the co-routine context for the transport |
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. |
|
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. |
|
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. |
|
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. |
|
fun exceptionHandler(handler: (Throwable) -> Unit): Unit
Sets an exception handler that will be called whenever an exception occurs during transport. |
|
suspend fun sendMessage(message: Message, transport: Transport, host: String, port: Int, requestURI: String = ""): Unit
Sends a message using the transport specified. |
|
suspend fun start(): Unit
Starts the hobbits transport. |
|
fun stop(): Unit
Stops the hobbits transport. |
fun CoroutineScope.asyncCompletion(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): AsyncCompletion
Starts new co-routine and returns its result as an implementation of AsyncCompletion. The running co-routine is cancelled when the resulting future is cancelled or otherwise completed. |
|
fun <T> CoroutineScope.asyncResult(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> T): AsyncResult<T>
Starts new co-routine and returns its result as an implementation of AsyncResult. The running co-outine is cancelled when the resulting future is cancelled or otherwise completed. |
|
suspend fun <R> CoroutineScope.retry(retryDelay: Long, block: suspend (Int) -> R?): R suspend fun <R> CoroutineScope.retry(retryDelay: Long, maxRetries: Int, block: suspend (Int) -> R?): R? suspend fun <R> CoroutineScope.retry(retryDelay: (Int) -> Long?, block: suspend (Int) -> R?): R?
Retry a suspending block until a non-null result is obtained. |