extending functionality for kilogin
This commit is contained in:
1 parent
5df6143c75
commit
7c0edfb898
6 files changed
+11
-7
No files matched your search
@@ -23,7 +23,7 @@ import net.sergeych.mp_tools.globalLaunch
|
||||
* it manually when it is not needed, otherwise it will continue to reconnect.
|
||||
*/
|
||||
class KiloClient<S>(
|
||||
localInterface: KiloInterface<S>,
|
||||
val localInterface: KiloInterface<S>,
|
||||
secretKey: SigningKey? = null,
|
||||
connectionDataFactory: ConnectionDataFactory<S>,
|
||||
) : RemoteInterface,
|
||||
|
||||
@@ -6,7 +6,7 @@ package net.sergeych.kiloparsec
|
||||
*
|
||||
* 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
|
||||
|
||||
|
||||
@@ -51,4 +51,6 @@ fun String.toNetworkAddress() : NetworkAddress {
|
||||
|
||||
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")
|
||||
suspend fun connectTcpDevice(host: String, port: Int) = connectTcpDevice(NetworkAddress(host,port))
|
||||
actual suspend fun connectTcpDevice(address: NetworkAddress): InetTransportDevice {
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.sergeych.kiloparsec.adapters
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.crypto2.initCrypto
|
||||
import net.sergeych.kiloparsec.adapter.UdpServer
|
||||
import net.sergeych.kiloparsec.adapter.acceptTcpDevice
|
||||
import net.sergeych.kiloparsec.adapter.connectTcpDevice
|
||||
@@ -11,8 +12,9 @@ import net.sergeych.kiloparsec.encodeToUByteArray
|
||||
import net.sergeych.mp_logger.Log
|
||||
import net.sergeych.synctools.ProtectedOp
|
||||
import net.sergeych.synctools.invoke
|
||||
import kotlin.test.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContains
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class NetworkTest {
|
||||
|
||||
@@ -33,6 +35,7 @@ class NetworkTest {
|
||||
|
||||
@Test
|
||||
fun tcpAsyncConnectionTest() = runTest {
|
||||
initCrypto()
|
||||
Log.connectConsole(Log.Level.DEBUG)
|
||||
|
||||
coroutineScope {
|
||||
|
||||
Reference in new issue
Block a user