Various bits and pieces
To easier work with TomP2P's Futures in Kotlin, this projects includes a few extension classes.
They are documented in place, but need this bit of documentation to tie them all together
Note, that all these classes employ TomP2P semantics. Think of these as a very thin layer upon TomP2P. E.g., a failure is only raised when no connection can be made. An empty response is no failure to TomP2P. To work more nicely with those responses, have a look at the higher-level Future classes.
BaseFuture
extension classes: these work on all Futures that TomP2P returns
FutureGet
extension classes work on all Get operations that TomP2P returns. Also includes all BaseFuture
extensions.
These fire on BaseFuture
's onComplete
. Therefore, the success status still needs to be checked.
These methods differ by these orthogonal concepts:
All
Is the response from the DHT transformed before returning it? Transformed responses have the suffix Custom
UserId
, but a User
object is returned in the calling method.
val BOOTSTRAP_PEER: Key<List<String>>
The list of peers to bootstrap to. Comma-separated list of "HOST:PORT" |
|
val PACKED_RESOURCES: Key<Boolean>
Build variable. Pack the resources in the JAR (otherwise, load from file system) |
|
val PEER_PORT: Key<Int>
The port the TomP2P peer runs on |
|
val WEBSERVER_IP: Key<String>
The IP the Webserver binds to |
|
val WEBSERVER_PORT: Key<Int>
The port the Webserver runs on |
|
val config: Configuration
The configuration object, defining the priorities in which configuration is read |
fun buildNewPeer(id: String = UUID.randomUUID().toString(), port: Int = findFreePort()): PeerDHT
Build a new peer |
|
fun findFreePort(): Int
Find a free port |
|
fun <OutputType> jsonTo(jsonString: String): OutputType
Convert JSON to |
|
fun toJson(message: Any): String
Convert to JSON |