public final class FramedConnection extends Objectimplements Closeable
Many methods in this API are synchronous: the call is completed before the method returns. This is typical for Java but atypical for SPDY. This is motivated by exception transparency: an IOException that was triggered by a certain caller can be caught and handled by that caller.
| Modifier and Type | Class and Description |
|---|---|
static class |
FramedConnection
|
static class |
FramedConnection
Listener of streams and settings initiated by the peer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this connection.
|
void |
flush()
|
long |
getIdleStartTimeNs()
Returns the time in ns when this connection became idle or Long.MAX_VALUE if connection is not idle.
|
Protocol |
getProtocol()
The protocol as selected using ALPN.
|
boolean |
isIdle()
Returns true if this connection is idle.
|
int |
maxConcurrentStreams()
|
FramedStream |
newStream(List
Returns a new locally-initiated stream.
|
int |
openStreamCount()
Returns the number of
open streams on this connection.
|
Ping |
ping()
Sends a ping frame to the peer.
|
FramedStream |
pushStream(int associatedStreamId, List
Returns a new server-initiated stream.
|
void |
sendConnectionPreface()
Sends a connection header if the current variant requires it.
|
void |
setSettings(Settings
Merges
settings into this peer's settings and sends them to the remote peer.
|
void |
shutdown(ErrorCode
Degrades this connection such that new streams can neither be created locally, nor accepted from the remote peer.
|
void |
writeData(int streamId, boolean outFinished, okio
Callers of this method are not thread safe, and sometimes on application threads.
|
public ProtocolgetProtocol()
public int openStreamCount()
open streams on this connection.
public boolean isIdle()
public int maxConcurrentStreams()
public long getIdleStartTimeNs()
public FramedStreampushStream(int associatedStreamId, List <Header > requestHeaders, boolean out) throws IOException
associatedStreamId - the stream that triggered the sender to create this stream.
out - true to create an output stream that we can use to send data to the remote peer. Corresponds to
FLAG_FIN.
IOException
public FramedStreamnewStream(List <Header > requestHeaders, boolean out, boolean in) throws IOException
out - true to create an output stream that we can use to send data to the remote peer. Corresponds to
FLAG_FIN.
in - true to create an input stream that the remote peer can use to send data to us. Corresponds to
FLAG_UNIDIRECTIONAL.
IOException
public void writeData(int streamId,
boolean outFinished,
okio.Buffer buffer,
long byteCount)
throws IOException
Writes are subject to the write window of the stream and the connection. Until there is a window sufficient to send byteCount, the caller will block. For example, a user of HttpURLConnection who flushes more bytes to the output stream than the connection's write window will block.
Zero byteCount writes are not subject to flow control and will not block. The only use case for zero byteCount is closing a flushed output stream.
IOException
public Pingping() throws IOException
IOException
public void flush()
throws IOException
IOException
public void shutdown(ErrorCodestatusCode) throws IOException
IOException
public void close()
throws IOException
close in interface
Closeable
close in interface
AutoCloseable
IOException
public void sendConnectionPreface()
throws IOException
FramedConnection.Builder.build() for all new connections.
IOException
public void setSettings(Settingssettings) throws IOException
settings into this peer's settings and sends them to the remote peer.
IOException