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