extending functionality for kilogin
This commit is contained in:
parent
5df6143c75
commit
7c0edfb898
@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "net.sergeych"
|
group = "net.sergeych"
|
||||||
version = "0.2.1-SNAPSHOT"
|
version = "0.2.2-SNAPSHOT"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -60,7 +60,7 @@ kotlin {
|
|||||||
val commonMain by getting {
|
val commonMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
|
||||||
|
|
||||||
// api("com.ionspin.kotlin:bignum:0.3.9")
|
// api("com.ionspin.kotlin:bignum:0.3.9")
|
||||||
api("io.ktor:ktor-client-core:$ktor_version")
|
api("io.ktor:ktor-client-core:$ktor_version")
|
||||||
|
@ -23,7 +23,7 @@ import net.sergeych.mp_tools.globalLaunch
|
|||||||
* it manually when it is not needed, otherwise it will continue to reconnect.
|
* it manually when it is not needed, otherwise it will continue to reconnect.
|
||||||
*/
|
*/
|
||||||
class KiloClient<S>(
|
class KiloClient<S>(
|
||||||
localInterface: KiloInterface<S>,
|
val localInterface: KiloInterface<S>,
|
||||||
secretKey: SigningKey? = null,
|
secretKey: SigningKey? = null,
|
||||||
connectionDataFactory: ConnectionDataFactory<S>,
|
connectionDataFactory: ConnectionDataFactory<S>,
|
||||||
) : RemoteInterface,
|
) : RemoteInterface,
|
||||||
|
@ -6,7 +6,7 @@ package net.sergeych.kiloparsec
|
|||||||
*
|
*
|
||||||
* BAse implementation registers relevant exceptions.
|
* BAse implementation registers relevant exceptions.
|
||||||
*/
|
*/
|
||||||
class KiloInterface<S> : LocalInterface<KiloScope<S>>() {
|
open class KiloInterface<S> : LocalInterface<KiloScope<S>>() {
|
||||||
|
|
||||||
internal var onConnectHandler: (KiloScope<S>.()->Unit) ? = null
|
internal var onConnectHandler: (KiloScope<S>.()->Unit) ? = null
|
||||||
|
|
||||||
|
@ -51,4 +51,6 @@ fun String.toNetworkAddress() : NetworkAddress {
|
|||||||
|
|
||||||
expect fun acceptTcpDevice(port: Int): Flow<InetTransportDevice>
|
expect fun acceptTcpDevice(port: Int): Flow<InetTransportDevice>
|
||||||
|
|
||||||
expect suspend fun connectTcpDevice(address: NetworkAddress): InetTransportDevice
|
expect suspend fun connectTcpDevice(address: NetworkAddress): InetTransportDevice
|
||||||
|
|
||||||
|
suspend fun connectTcpDevice(address: String) = connectTcpDevice(address.toNetworkAddress())
|
||||||
|
@ -33,7 +33,6 @@ actual fun acceptTcpDevice(port: Int): Flow<InetTransportDevice> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun connectTcpDevice(address: String) = connectTcpDevice(address.toNetworkAddress())
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
suspend fun connectTcpDevice(host: String, port: Int) = connectTcpDevice(NetworkAddress(host,port))
|
suspend fun connectTcpDevice(host: String, port: Int) = connectTcpDevice(NetworkAddress(host,port))
|
||||||
actual suspend fun connectTcpDevice(address: NetworkAddress): InetTransportDevice {
|
actual suspend fun connectTcpDevice(address: NetworkAddress): InetTransportDevice {
|
||||||
|
@ -2,6 +2,7 @@ package net.sergeych.kiloparsec.adapters
|
|||||||
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import net.sergeych.crypto2.initCrypto
|
||||||
import net.sergeych.kiloparsec.adapter.UdpServer
|
import net.sergeych.kiloparsec.adapter.UdpServer
|
||||||
import net.sergeych.kiloparsec.adapter.acceptTcpDevice
|
import net.sergeych.kiloparsec.adapter.acceptTcpDevice
|
||||||
import net.sergeych.kiloparsec.adapter.connectTcpDevice
|
import net.sergeych.kiloparsec.adapter.connectTcpDevice
|
||||||
@ -11,8 +12,9 @@ import net.sergeych.kiloparsec.encodeToUByteArray
|
|||||||
import net.sergeych.mp_logger.Log
|
import net.sergeych.mp_logger.Log
|
||||||
import net.sergeych.synctools.ProtectedOp
|
import net.sergeych.synctools.ProtectedOp
|
||||||
import net.sergeych.synctools.invoke
|
import net.sergeych.synctools.invoke
|
||||||
import kotlin.test.*
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertContains
|
import kotlin.test.assertContains
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
class NetworkTest {
|
class NetworkTest {
|
||||||
|
|
||||||
@ -33,6 +35,7 @@ class NetworkTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun tcpAsyncConnectionTest() = runTest {
|
fun tcpAsyncConnectionTest() = runTest {
|
||||||
|
initCrypto()
|
||||||
Log.connectConsole(Log.Level.DEBUG)
|
Log.connectConsole(Log.Level.DEBUG)
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user