public interface Session
A Session
represents the client-side endpoint of a SPDY connection to a single origin server.
Once a Session
has been obtained, it can be used to open SPDY streams:
Session session = ...; SynInfo synInfo = new SynInfo(true); session.push(synInfo, new Stream.FrameListener.Adapter() { public void onReply(Stream stream, ReplyInfo replyInfo) { // Stream reply received } });
A Session
is the active part of the endpoint, and by calling its API applications can generate
events on the connection; conversely SessionFrameListener
is the passive part of the endpoint, and
has callbacks that are invoked when events happen on the connection.
SessionFrameListener
Modifier and Type | Interface and Description |
---|---|
static interface |
Session.Listener
Super interface for listeners with callbacks that are invoked on specific session events.
|
static interface |
Session.StreamListener
Specialized listener that is invoked upon creation and removal of streams.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(Session.Listener listener)
Registers the given
listener to be notified of session events. |
Object |
getAttribute(String key) |
InetSocketAddress |
getLocalAddress() |
InetSocketAddress |
getRemoteAddress() |
Stream |
getStream(int streamId) |
Set<Stream> |
getStreams() |
short |
getVersion() |
void |
goAway(GoAwayInfo goAwayInfo)
Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.
|
void |
goAway(GoAwayInfo goAwayInfo,
Callback callback)
Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.
|
PingResultInfo |
ping(PingInfo pingInfo)
Sends synchronously a PING, normally to measure round-trip time.
|
void |
ping(PingInfo pingInfo,
Promise<PingResultInfo> promise)
Sends asynchronously a PING, normally to measure round-trip time.
|
Object |
removeAttribute(String key) |
void |
removeListener(Session.Listener listener)
Deregisters the give
listener from being notified of session events. |
void |
rst(RstInfo rstInfo)
Sends synchronously a RST_STREAM to abort a stream.
|
void |
rst(RstInfo rstInfo,
Callback callback)
Sends asynchronously a RST_STREAM to abort a stream.
|
void |
setAttribute(String key,
Object value) |
void |
settings(SettingsInfo settingsInfo)
Sends synchronously a SETTINGS to configure the SPDY connection.
|
void |
settings(SettingsInfo settingsInfo,
Callback callback)
Sends asynchronously a SETTINGS to configure the SPDY connection.
|
Stream |
syn(SynInfo synInfo,
StreamFrameListener listener)
Sends a SYN_FRAME to create a new
SPDY stream . |
void |
syn(SynInfo synInfo,
StreamFrameListener listener,
Promise<Stream> promise)
Sends asynchronously a SYN_FRAME to create a new
SPDY stream . |
short getVersion()
void addListener(Session.Listener listener)
Registers the given listener
to be notified of session events.
listener
- the listener to registerremoveListener(Listener)
void removeListener(Session.Listener listener)
Deregisters the give listener
from being notified of session events.
listener
- the listener to deregisteraddListener(Listener)
Stream syn(SynInfo synInfo, StreamFrameListener listener) throws ExecutionException, InterruptedException, TimeoutException
Sends a SYN_FRAME to create a new SPDY stream
.
Callers may use the returned Stream for example, to send data frames.
synInfo
- the metadata to send on stream creationlistener
- the listener to invoke when events happen on the stream just createdExecutionException
InterruptedException
TimeoutException
syn(SynInfo, StreamFrameListener, Promise)
void syn(SynInfo synInfo, StreamFrameListener listener, Promise<Stream> promise)
Sends asynchronously a SYN_FRAME to create a new SPDY stream
.
Callers may pass a non-null completion callback to be notified of when the stream has been created and use the stream, for example, to send data frames.
synInfo
- the metadata to send on stream creationlistener
- the listener to invoke when events happen on the stream just createdpromise
- the completion callback that gets notified of stream creationsyn(SynInfo, StreamFrameListener)
void rst(RstInfo rstInfo) throws InterruptedException, ExecutionException, TimeoutException
Sends synchronously a RST_STREAM to abort a stream.
rstInfo
- the metadata to reset the streamInterruptedException
ExecutionException
TimeoutException
rst(RstInfo, Callback)
void rst(RstInfo rstInfo, Callback callback)
Sends asynchronously a RST_STREAM to abort a stream.
Callers may pass a non-null completion callback to be notified of when the reset has been actually sent.
rstInfo
- the metadata to reset the streamcallback
- the completion callback that gets notified of reset's sendrst(RstInfo)
void settings(SettingsInfo settingsInfo) throws ExecutionException, InterruptedException, TimeoutException
Sends synchronously a SETTINGS to configure the SPDY connection.
settingsInfo
- the metadata to sendExecutionException
InterruptedException
TimeoutException
settings(SettingsInfo, Callback)
void settings(SettingsInfo settingsInfo, Callback callback)
Sends asynchronously a SETTINGS to configure the SPDY connection.
Callers may pass a non-null completion callback to be notified of when the settings has been actually sent.
settingsInfo
- the metadata to sendcallback
- the completion callback that gets notified of settings' sendsettings(SettingsInfo)
PingResultInfo ping(PingInfo pingInfo) throws ExecutionException, InterruptedException, TimeoutException
Sends synchronously a PING, normally to measure round-trip time.
pingInfo
- ExecutionException
InterruptedException
TimeoutException
ping(PingInfo, Promise)
void ping(PingInfo pingInfo, Promise<PingResultInfo> promise)
Sends asynchronously a PING, normally to measure round-trip time.
Callers may pass a non-null completion callback to be notified of when the ping has been actually sent.
pingInfo
- promise
- the completion callback that gets notified of ping's sendping(PingInfo)
void goAway(GoAwayInfo goAwayInfo) throws ExecutionException, InterruptedException, TimeoutException
Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.
goAwayInfo
- ExecutionException
InterruptedException
TimeoutException
goAway(GoAwayInfo, Callback)
void goAway(GoAwayInfo goAwayInfo, Callback callback)
Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.
Callers may pass a non-null completion callback to be notified of when the go away has been actually sent.
goAwayInfo
- callback
- the completion callback that gets notified of go away's sendgoAway(GoAwayInfo)
Set<Stream> getStreams()
getStream(int)
Stream getStream(int streamId)
streamId
- the id of the stream to retrievegetStreams()
Object getAttribute(String key)
key
- the attribute keysetAttribute(String, Object)
void setAttribute(String key, Object value)
key
- the attribute keyvalue
- an arbitrary object to associate with the given key to this sessiongetAttribute(String)
,
removeAttribute(String)
Object removeAttribute(String key)
key
- the attribute keysetAttribute(String, Object)
InetSocketAddress getLocalAddress()
InetSocketAddress getRemoteAddress()
Copyright © 1995-2015 Webtide. All Rights Reserved.