@@ -29,6 +29,7 @@ import com.google.firebase.ai.type.MediaData
29
29
import com.google.firebase.ai.type.PublicPreviewAPI
30
30
import com.google.firebase.ai.type.SessionAlreadyReceivingException
31
31
import io.ktor.websocket.close
32
+ import kotlinx.coroutines.isActive
32
33
import kotlinx.coroutines.reactive.asPublisher
33
34
import org.reactivestreams.Publisher
34
35
@@ -51,6 +52,12 @@ public abstract class LiveSessionFutures internal constructor() {
51
52
functionCallHandler : ((FunctionCallPart ) -> FunctionResponsePart )?
52
53
): ListenableFuture <Unit >
53
54
55
+ /* * Indicates whether the underlying websocket connection is active. */
56
+ public abstract fun isActive (): ListenableFuture <Boolean >
57
+
58
+ /* * Indicates whether an audio conversation is being used for this session object. */
59
+ public abstract fun isAudioConversationActive (): ListenableFuture <Boolean >
60
+
54
61
/* *
55
62
* Starts an audio conversation with the model, which can only be stopped using
56
63
* [stopAudioConversation].
@@ -169,6 +176,11 @@ public abstract class LiveSessionFutures internal constructor() {
169
176
override fun startAudioConversation () =
170
177
SuspendToFutureAdapter .launchFuture { session.startAudioConversation() }
171
178
179
+ override fun isActive () = SuspendToFutureAdapter .launchFuture { session.isActive() }
180
+
181
+ override fun isAudioConversationActive () =
182
+ SuspendToFutureAdapter .launchFuture { session.isAudioConversationActive() }
183
+
172
184
override fun stopAudioConversation () =
173
185
SuspendToFutureAdapter .launchFuture { session.stopAudioConversation() }
174
186
0 commit comments