org.whispersystems.signalservice.internal.websocket.WebSocketConnection.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signal-service-java Show documentation
Show all versions of signal-service-java Show documentation
Signal Service communication library for Java, unofficial fork
package org.whispersystems.signalservice.internal.websocket
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Single
import org.whispersystems.signalservice.api.websocket.WebSocketConnectionState
import java.io.IOException
import java.util.Optional
import java.util.concurrent.TimeoutException
/**
* Common interface for the web socket connection API
*
* At the time of this writing there are two implementations available:
* - OkHttpWebSocketConnection - the original Android client implementation in Java using OkHttp library
* - LibSignalChatConnection - the wrapper around libsignal's [org.signal.libsignal.net.ChatService]
*/
interface WebSocketConnection {
val name: String
fun connect(): Observable
fun isDead(): Boolean
fun disconnect()
@Throws(IOException::class)
fun sendRequest(request: WebSocketRequestMessage): Single
@Throws(IOException::class)
fun sendKeepAlive()
fun readRequestIfAvailable(): Optional
@Throws(TimeoutException::class, IOException::class)
fun readRequest(timeoutMillis: Long): WebSocketRequestMessage
@Throws(IOException::class)
fun sendResponse(response: WebSocketResponseMessage?)
}