Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
Update dependency io.ktor:ktor-network to v2 (#37)
Browse files Browse the repository at this point in the history
* Update dependency io.ktor:ktor-network to v2

* Ktor 2.0

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Yuya Matsuo <[email protected]>
  • Loading branch information
3 people authored Jun 20, 2022
1 parent e2e9fd6 commit 0dd646d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kotlin = "1.6.21"
dokka = "1.7.0"
compose = "1.2.0-rc01"
# https://ktor.io/changelog/1.6/
ktor = "1.6.8"
ktor = "2.0.2"
# https://github.com/Kotlin/kotlinx.coroutines/releases
coroutines = "1.6.3"
# https://github.com/detekt/detekt/releases
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.niusounds.libreastream.receiver

import io.ktor.network.selector.ActorSelectorManager
import io.ktor.network.sockets.InetSocketAddress
import io.ktor.network.sockets.aSocket
import io.ktor.utils.io.core.readByteBuffer
import java.net.InetSocketAddress
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.consumeAsFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onCompletion
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.coroutines.CoroutineContext

/**
* Receive UDP data with Ktor.
Expand All @@ -23,7 +23,7 @@ class KtorUdpReceiver(
override fun receive(): Flow<ByteBuffer> {
val server = aSocket(ActorSelectorManager(ioContext))
.udp()
.bind(InetSocketAddress(port))
.bind(InetSocketAddress("", port))

return server.incoming.consumeAsFlow()
.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import com.niusounds.libreastream.ReaStream
import io.ktor.network.selector.ActorSelectorManager
import io.ktor.network.sockets.ConnectedDatagramSocket
import io.ktor.network.sockets.Datagram
import io.ktor.network.sockets.InetSocketAddress
import io.ktor.network.sockets.aSocket
import io.ktor.util.network.NetworkAddress
import io.ktor.utils.io.core.ByteReadPacket
import java.nio.ByteBuffer
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.nio.ByteBuffer
import kotlin.coroutines.CoroutineContext

/**
* Receive UDP data with Ktor.
Expand All @@ -23,7 +23,7 @@ class KtorUdpSender(
private val client: ConnectedDatagramSocket by lazy {
aSocket(ActorSelectorManager(ioContext))
.udp()
.connect(NetworkAddress(host, port))
.connect(InetSocketAddress(host, port))
}

override suspend fun send(data: ByteBuffer) = withContext(ioContext) {
Expand Down

0 comments on commit 0dd646d

Please sign in to comment.