-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
131 additions
and
18 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
rsocket-core/src/commonMain/kotlin/io/rsocket/kotlin/configuration/KeepAliveConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2015-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.rsocket.kotlin.configuration | ||
|
||
import io.rsocket.kotlin.keepalive.* | ||
import kotlin.time.* | ||
|
||
public sealed interface KeepAliveConfiguration { | ||
public fun receiver(handler: KeepAliveReceiver) | ||
} | ||
|
||
public sealed interface ClientKeepAliveConfiguration : KeepAliveConfiguration { | ||
public fun interval(value: Duration) | ||
public fun maxLifetime(value: Duration) | ||
public fun dataGenerator(generator: KeepAliveDataGenerator) | ||
} | ||
|
||
public sealed interface ServerKeepAliveConfiguration : KeepAliveConfiguration { | ||
public val interval: Duration | ||
public val maxLifetime: Duration | ||
public val sender: KeepAliveSender | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
rsocket-core/src/commonMain/kotlin/io/rsocket/kotlin/configuration/RSocketServer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2015-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.rsocket.kotlin.configuration | ||
|
||
import io.rsocket.kotlin.transport.* | ||
import kotlinx.coroutines.* | ||
import kotlin.coroutines.* | ||
|
||
public sealed interface RSocketServer : CoroutineScope { | ||
public suspend fun <Instance : RSocketServerInstance> start( | ||
transport: RSocketServerTransport<Instance>, | ||
configurator: RSocketSessionConfigurator<out ServerSessionConfiguration>, | ||
): Instance | ||
} | ||
|
||
public sealed interface RSocketServerBuilder { | ||
|
||
} | ||
|
||
public fun RSocketServer( | ||
context: CoroutineContext, | ||
builder: RSocketServerBuilder.() -> Unit = {}, | ||
): RSocketServer { | ||
TODO() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ package io.rsocket.kotlin.configuration | |
|
||
// TODO: move to another package | ||
public sealed interface RSocketSession | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
rsocket-core/src/commonMain/kotlin/io/rsocket/kotlin/keepalive/new.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2015-2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.rsocket.kotlin.keepalive | ||
|
||
import io.ktor.utils.io.core.* | ||
|
||
//can be used by client only, `generateData` is called when new keep alive frame is generated, | ||
// f.e. it can contain current timestamp to calculate latency | ||
public fun interface KeepAliveDataGenerator { | ||
public fun generateData(): ByteReadPacket | ||
} | ||
|
||
//can be registered by both client and server | ||
//TODO: flow api | ||
public fun interface KeepAliveReceiver { | ||
public fun receiveKeepAlive(respond: Boolean, data: ByteReadPacket) | ||
} | ||
|
||
//implemented internally | ||
//can be used by server only | ||
//TODO: flow api | ||
public sealed interface KeepAliveSender { | ||
public suspend fun sendKeepAlive(data: ByteReadPacket) | ||
} |