11/*
2- * Copyright 2015-2024 the original author or authors.
2+ * Copyright 2015-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package io.rsocket.kotlin.transport
1818
19+ import kotlinx.coroutines.*
1920import kotlinx.io.*
2021
2122// all methods can be called from any thread/context at any time
2223// should be accessed only internally
2324// should be implemented only by transports
2425@RSocketTransportApi
25- public sealed interface RSocketConnection
26-
27- @RSocketTransportApi
28- public fun interface RSocketConnectionHandler {
29- public suspend fun handleConnection (connection : RSocketConnection )
30- }
26+ public sealed interface RSocketConnection : CoroutineScope
3127
3228@RSocketTransportApi
3329public interface RSocketSequentialConnection : RSocketConnection {
34- // TODO: is it needed for connection?
35- public val isClosedForSend: Boolean
36-
3730 // throws if frame not sent
3831 // streamId=0 should be sent earlier
3932 public suspend fun sendFrame (streamId : Int , frame : Buffer )
@@ -47,9 +40,8 @@ public interface RSocketMultiplexedConnection : RSocketConnection {
4740 public suspend fun createStream (): Stream
4841 public suspend fun acceptStream (): Stream ?
4942
50- public interface Stream : AutoCloseable {
51- public val isClosedForSend: Boolean
52-
43+ @RSocketTransportApi
44+ public interface Stream : CoroutineScope {
5345 // 0 - highest priority
5446 // Int.MAX - lowest priority
5547 public fun setSendPriority (priority : Int )
@@ -59,10 +51,5 @@ public interface RSocketMultiplexedConnection : RSocketConnection {
5951
6052 // null if no more frames could be received
6153 public suspend fun receiveFrame (): Buffer ?
62-
63- // closing stream will send buffered frames (if needed)
64- // sending/receiving frames will be not possible after it
65- // should not throw
66- override fun close ()
6754 }
6855}
0 commit comments