@@ -29,6 +29,7 @@ import com.google.firebase.ai.type.MediaData
2929import com.google.firebase.ai.type.PublicPreviewAPI
3030import com.google.firebase.ai.type.SessionAlreadyReceivingException
3131import io.ktor.websocket.close
32+ import kotlinx.coroutines.isActive
3233import kotlinx.coroutines.reactive.asPublisher
3334import org.reactivestreams.Publisher
3435
@@ -51,6 +52,12 @@ public abstract class LiveSessionFutures internal constructor() {
5152 functionCallHandler : ((FunctionCallPart ) -> FunctionResponsePart )?
5253 ): ListenableFuture <Unit >
5354
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+
5461 /* *
5562 * Starts an audio conversation with the model, which can only be stopped using
5663 * [stopAudioConversation].
@@ -169,6 +176,11 @@ public abstract class LiveSessionFutures internal constructor() {
169176 override fun startAudioConversation () =
170177 SuspendToFutureAdapter .launchFuture { session.startAudioConversation() }
171178
179+ override fun isActive () = SuspendToFutureAdapter .launchFuture { session.isActive() }
180+
181+ override fun isAudioConversationActive () =
182+ SuspendToFutureAdapter .launchFuture { session.isAudioConversationActive() }
183+
172184 override fun stopAudioConversation () =
173185 SuspendToFutureAdapter .launchFuture { session.stopAudioConversation() }
174186
0 commit comments