dev.oh
dev.oh

Reputation: 1

How to wait for socket response and return while using socket.io in Android

override fun onProduce(
            transport: Transport,
            kind: String,
            rtpParameters: String,
            appData: String?
        ): String {
            Log.d(TAG, "sendTransportListener: onProduce")
            var id = ""

            val params = JSONObject().apply {
                put("kind", kind)
                put("rtpParameters", JSONObject(rtpParameters))
                put("appData", appData)
            }

                socket.emit("transport-produce", params, Ack {
                    val data = it[0] as JSONObject
                    id = data.optString("id")
                })

            return id
        }

Is there a way to receive the id and return the id when an ACK call comes after calling socket.emit?

Currently the socket is called after the return id is returned.

Upvotes: 0

Views: 13

Answers (0)

Related Questions