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.syn(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) |
Stream |
getStream(int streamId) |
Set<Stream> |
getStreams() |
short |
getVersion() |
Future<Void> |
goAway()
Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.
|
void |
goAway(long timeout,
TimeUnit unit,
Handler<Void> handler)
Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.
|
Future<PingInfo> |
ping()
Sends asynchronously a PING, normally to measure round-trip time.
|
void |
ping(long timeout,
TimeUnit unit,
Handler<PingInfo> handler)
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. |
Future<Void> |
rst(RstInfo rstInfo)
Sends asynchronously a RST_STREAM to abort a stream.
|
void |
rst(RstInfo rstInfo,
long timeout,
TimeUnit unit,
Handler<Void> handler)
Sends asynchronously a RST_STREAM to abort a stream.
|
void |
setAttribute(String key,
Object value) |
Future<Void> |
settings(SettingsInfo settingsInfo)
Sends asynchronously a SETTINGS to configure the SPDY connection.
|
void |
settings(SettingsInfo settingsInfo,
long timeout,
TimeUnit unit,
Handler<Void> handler)
Sends asynchronously a SETTINGS to configure the SPDY connection.
|
Future<Stream> |
syn(SynInfo synInfo,
StreamFrameListener listener)
Sends asynchronously a SYN_FRAME to create a new
SPDY stream . |
void |
syn(SynInfo synInfo,
StreamFrameListener listener,
long timeout,
TimeUnit unit,
Handler<Stream> handler)
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)
Future<Stream> syn(SynInfo synInfo, StreamFrameListener listener)
Sends asynchronously a SYN_FRAME to create a new SPDY stream
.
Callers may use the returned future to wait for the stream to be 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 createdsyn(SynInfo, StreamFrameListener, long, TimeUnit, Handler)
void syn(SynInfo synInfo, StreamFrameListener listener, long timeout, TimeUnit unit, Handler<Stream> handler)
Sends asynchronously a SYN_FRAME to create a new SPDY stream
.
Callers may pass a non-null completion handler 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 createdtimeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of stream creationsyn(SynInfo, StreamFrameListener)
Future<Void> rst(RstInfo rstInfo)
Sends asynchronously a RST_STREAM to abort a stream.
Callers may use the returned future to wait for the reset to be sent.
rstInfo
- the metadata to reset the streamrst(RstInfo, long, TimeUnit, Handler)
void rst(RstInfo rstInfo, long timeout, TimeUnit unit, Handler<Void> handler)
Sends asynchronously a RST_STREAM to abort a stream.
Callers may pass a non-null completion handler to be notified of when the reset has been actually sent.
rstInfo
- the metadata to reset the streamtimeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of reset's sendrst(RstInfo)
Future<Void> settings(SettingsInfo settingsInfo)
Sends asynchronously a SETTINGS to configure the SPDY connection.
Callers may use the returned future to wait for the settings to be sent.
settingsInfo
- the metadata to sendsettings(SettingsInfo, long, TimeUnit, Handler)
void settings(SettingsInfo settingsInfo, long timeout, TimeUnit unit, Handler<Void> handler)
Sends asynchronously a SETTINGS to configure the SPDY connection.
Callers may pass a non-null completion handler to be notified of when the settings has been actually sent.
settingsInfo
- the metadata to sendtimeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of settings' sendsettings(SettingsInfo)
Future<PingInfo> ping()
Sends asynchronously a PING, normally to measure round-trip time.
Callers may use the returned future to wait for the ping to be sent.
ping(long, TimeUnit, Handler)
void ping(long timeout, TimeUnit unit, Handler<PingInfo> handler)
Sends asynchronously a PING, normally to measure round-trip time.
Callers may pass a non-null completion handler to be notified of when the ping has been actually sent.
timeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of ping's sendping()
Future<Void> goAway()
Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.
Callers may use the returned future to wait for the go away to be sent.
goAway(long, TimeUnit, Handler)
void goAway(long timeout, TimeUnit unit, Handler<Void> handler)
Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.
Callers may pass a non-null completion handler to be notified of when the go away has been actually sent.
timeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of go away's sendgoAway()
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)
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.