I have a use case where I unsubscribe a channel and then subscribe again.
But somehow multiple duplicate response is received .
Below are my subscribe & unsubscribe methods
`
fun subscribeChannel() {
viewModelScope.launchWithException {
if (socketRepository.isSocketConnected) {
socketRepository.subscribeChannel(coinName, ChannelNameConstants.CHANNEL_ORDER_BOOK)
} else {
val socketFlow = socketRepository.getWebSocketEvents()
socketFlow.collect {
when (it) {
is WebSocket.Event.OnConnectionOpened<*> -> {
socketRepository.isSocketConnected = true
socketRepository.subscribeChannel(coinName, ChannelNameConstants.CHANNEL_ORDER_BOOK)
}
is WebSocket.Event.OnConnectionClosed,
is WebSocket.Event.OnConnectionFailed -> {
socketRepository.isSocketConnected = false
}
}
}
}
}
}
fun unsubscribeChannel(coinName: String, channelName: String) {
socketService.sendUnsubscribe(
ChannelData(
channelName = "$channelName ${SubscriptionType.UNSUBSCRIBE.value}",
data = coinName
)
)
}
`
I have a use case where I unsubscribe a channel and then subscribe again. But somehow multiple duplicate response is received . Below are my subscribe & unsubscribe methods `