splitting bracnhes
This commit is contained in:
parent
6c10c2e578
commit
8fc24567f0
@ -15,11 +15,25 @@ interface NetworkAddress {
|
||||
* Multiplatform datagram abstraction
|
||||
*/
|
||||
interface Datagram {
|
||||
/**
|
||||
* Received message
|
||||
*/
|
||||
val message: UByteArray
|
||||
|
||||
/**
|
||||
* Address from where the message was sent
|
||||
*/
|
||||
val address: NetworkAddress
|
||||
|
||||
/**
|
||||
* Send a datagram in response, e.g., to the [address].
|
||||
* This method is optimized per single per-datagram use. If you need to send many datagram, use [DatagramConnector].
|
||||
*/
|
||||
suspend fun respondWith(message: UByteArray)
|
||||
}
|
||||
interface DatagramReceiver {
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
interface DatagramConnector: AutoCloseable {
|
||||
|
||||
val incoming: ReceiveChannel<Datagram>
|
||||
suspend fun send(message: UByteArray, networkAddress: NetworkAddress)
|
||||
@ -30,7 +44,7 @@ interface DatagramReceiver {
|
||||
|
||||
suspend fun send(message: UByteArray,host: String,port: Int) =
|
||||
send(message, NetworkAddress(host,port))
|
||||
fun close()
|
||||
override fun close()
|
||||
}
|
||||
|
||||
expect fun networkAddressOf(address: String): NetworkAddress
|
||||
|
Loading…
x
Reference in New Issue
Block a user