public abstract class AbstractCBLWebSocket extends C4Socket
So, some assumptions. If you are here:
State transition: Things kick off when Core calls openSocket. We are now in the state CONNECTING. In response, we ask OkHttp to open a connection to the remote. In the happy case, OkHttp successfully makes the connection to the remote. That causes a callback to CBLWebSocketListener.onOpen. We proxy that call to Core. The connection is now OPEN. After that, the two sides chat. If Core has something to say, we get a call to send(). We proxy that call to OkHttp, and, when the data has been sent, call back to Core with completedWrite(). If the remote has something to say, we get a call to one of the two CBLWebSocketListener.onMessage() methods and proxy the content to Core by calling received() Eventually, someone decides to close the connection. If it is the remote, we get a call to CBLWebSocketListener.onClosing(). We proxy that to Core, which, surprisingly, turns right around and proxies it back to us, by calling close(). If it is Core that decides to close the connection, we get a call to requestClose(). That should result in a call to CBLWebSocketListener.onClosed().
This class is going to cause deadlocks. While C4Socket does not synchronise outbound messages (Core to remote) this class does. Messages headed in either direction (to or from core) seize the object lock (from C4NativePeer). If message processing seizes any other locks, the two lock may be seized in the opposite order depending on which way the message is going. This invites deadlock.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_HEARTBEAT_SEC |
static String |
HEADER_COOKIES |
NO_FRAMING, WEB_SOCKET_CLIENT_FRAMING, WEB_SOCKET_SERVER_FRAMING
Modifier and Type | Method and Description |
---|---|
static int |
addKeyManager(KeyManager keyManager) |
void |
close() |
okhttp3.OkHttpClient |
getOkHttpSocketFactory() |
Map<String,Object> |
getOptions() |
String |
toString() |
public static final int DEFAULT_HEARTBEAT_SEC
public static final String HEADER_COOKIES
public static int addKeyManager(@NonNull KeyManager keyManager)
@NonNull public String toString()
toString
in class C4NativePeer
public void close()
@NonNull public final okhttp3.OkHttpClient getOkHttpSocketFactory()