Skip to content

Commit dbb4831

Browse files
committed
Fix: ensure ID is correctly set for client requests
1 parent a8a13d9 commit dbb4831

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pipecat-client-android/src/main/java/ai/pipecat/client/PipecatClient.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ internal const val RTVI_PROTOCOL_VERSION = "1.0.0"
4949
* @param options Additional options for configuring the client and backend.
5050
*/
5151
@Suppress("unused")
52-
open class PipecatClient<TransportType: Transport<ConnectParams>, ConnectParams>(
52+
open class PipecatClient<TransportType : Transport<ConnectParams>, ConnectParams>(
5353
private val transport: TransportType,
5454
private val options: PipecatClientOptions,
5555
) {
@@ -350,6 +350,7 @@ open class PipecatClient<TransportType: Transport<ConnectParams>, ConnectParams>
350350
fun sendClientMessage(msgType: String, data: Value = Value.Null): Future<Unit, RTVIError> =
351351
sendMessage(
352352
MsgClientToServer.ClientMessage(
353+
id = UUID.randomUUID().toString(),
353354
msgType = msgType,
354355
data = JSON_INSTANCE.encodeToJsonElement(data)
355356
)
@@ -370,7 +371,13 @@ open class PipecatClient<TransportType: Transport<ConnectParams>, ConnectParams>
370371

371372
val future = responseWaiters.waitFor(id)
372373

373-
sendClientMessage(msgType, data)
374+
sendMessage(
375+
MsgClientToServer.ClientMessage(
376+
id = id,
377+
msgType = msgType,
378+
data = JSON_INSTANCE.encodeToJsonElement<Value>(data)
379+
)
380+
)
374381
.withErrorCallback { responseWaiters.reject(id, it) }
375382
.chain { future }
376383
.mapToResult { catchExceptions { JSON_INSTANCE.decodeFromJsonElement(it) } }

pipecat-client-android/src/main/java/ai/pipecat/client/transport/MsgClientToServer.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ data class MsgClientToServer private constructor(
8484
)
8585

8686
fun ClientMessage(
87+
id: String,
8788
msgType: String,
8889
data: JsonElement? = null
8990
) = MsgClientToServer(
91+
id = id,
9092
type = Type.ClientMessage,
9193
data = JSON_INSTANCE.encodeToJsonElement(
9294
DataMessage.serializer(),

0 commit comments

Comments
 (0)