public class StandardSession extends Object implements ISession, Parser.Listener, Handler<StandardSession.FrameBytes>, Dumpable
Modifier and Type | Class and Description |
---|---|
static interface |
StandardSession.FrameBytes |
Session.Listener, Session.StreamListener
Parser.Listener.Adapter
Handler.Adapter<C>
Constructor and Description |
---|
StandardSession(short version,
ByteBufferPool bufferPool,
Executor threadPool,
ScheduledExecutorService scheduler,
Controller<StandardSession.FrameBytes> controller,
IdleListener idleListener,
int initialStreamId,
SessionFrameListener listener,
Generator generator,
FlowControlStrategy flowControlStrategy) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(Session.Listener listener)
Registers the given
listener to be notified of session events. |
protected void |
close() |
void |
completed(StandardSession.FrameBytes frameBytes)
Callback invoked when the operation completes.
|
<C> void |
control(IStream stream,
ControlFrame frame,
long timeout,
TimeUnit unit,
Handler<C> handler,
C context) |
<C> void |
data(IStream stream,
DataInfo dataInfo,
long timeout,
TimeUnit unit,
Handler<C> handler,
C context) |
String |
dump() |
void |
dump(Appendable out,
String indent) |
void |
failed(StandardSession.FrameBytes frameBytes,
Throwable x)
Callback invoked when the operation fails.
|
void |
flush()
Initiates the flush of data to the other peer.
|
Object |
getAttribute(String key) |
IStream |
getStream(int streamId) |
Set<Stream> |
getStreams() |
short |
getVersion() |
int |
getWindowSize() |
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.
|
void |
onControlFrame(ControlFrame frame) |
void |
onDataFrame(DataFrame frame,
ByteBuffer data) |
void |
onSessionException(SessionException x) |
void |
onStreamException(StreamException x) |
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.
|
void |
setWindowSize(int initialWindowSize) |
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 . |
String |
toString() |
protected void |
write(ByteBuffer buffer,
Handler<StandardSession.FrameBytes> handler,
StandardSession.FrameBytes frameBytes) |
public StandardSession(short version, ByteBufferPool bufferPool, Executor threadPool, ScheduledExecutorService scheduler, Controller<StandardSession.FrameBytes> controller, IdleListener idleListener, int initialStreamId, SessionFrameListener listener, Generator generator, FlowControlStrategy flowControlStrategy)
public short getVersion()
getVersion
in interface Session
public void addListener(Session.Listener listener)
Session
Registers the given listener
to be notified of session events.
addListener
in interface Session
listener
- the listener to registerSession.removeListener(Listener)
public void removeListener(Session.Listener listener)
Session
Deregisters the give listener
from being notified of session events.
removeListener
in interface Session
listener
- the listener to deregisterSession.addListener(Listener)
public Future<Stream> syn(SynInfo synInfo, StreamFrameListener listener)
Session
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.
syn
in interface Session
synInfo
- the metadata to send on stream creationlistener
- the listener to invoke when events happen on the stream just createdSession.syn(SynInfo, StreamFrameListener, long, TimeUnit, Handler)
public void syn(SynInfo synInfo, StreamFrameListener listener, long timeout, TimeUnit unit, Handler<Stream> handler)
Session
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.
syn
in interface Session
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 creationSession.syn(SynInfo, StreamFrameListener)
public Future<Void> rst(RstInfo rstInfo)
Session
Sends asynchronously a RST_STREAM to abort a stream.
Callers may use the returned future to wait for the reset to be sent.
rst
in interface Session
rstInfo
- the metadata to reset the streamSession.rst(RstInfo, long, TimeUnit, Handler)
public void rst(RstInfo rstInfo, long timeout, TimeUnit unit, Handler<Void> handler)
Session
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.
rst
in interface Session
rstInfo
- the metadata to reset the streamtimeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of reset's sendSession.rst(RstInfo)
public Future<Void> settings(SettingsInfo settingsInfo)
Session
Sends asynchronously a SETTINGS to configure the SPDY connection.
Callers may use the returned future to wait for the settings to be sent.
settings
in interface Session
settingsInfo
- the metadata to sendSession.settings(SettingsInfo, long, TimeUnit, Handler)
public void settings(SettingsInfo settingsInfo, long timeout, TimeUnit unit, Handler<Void> handler)
Session
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.
settings
in interface Session
settingsInfo
- the metadata to sendtimeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of settings' sendSession.settings(SettingsInfo)
public Future<PingInfo> ping()
Session
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
in interface Session
Session.ping(long, TimeUnit, Handler)
public void ping(long timeout, TimeUnit unit, Handler<PingInfo> handler)
Session
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.
ping
in interface Session
timeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of ping's sendSession.ping()
public Future<Void> goAway()
Session
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
in interface Session
Session.goAway(long, TimeUnit, Handler)
public void goAway(long timeout, TimeUnit unit, Handler<Void> handler)
Session
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.
goAway
in interface Session
timeout
- the operation's timeoutunit
- the timeout's unithandler
- the completion handler that gets notified of go away's sendSession.goAway()
public Set<Stream> getStreams()
getStreams
in interface Session
Session.getStream(int)
public IStream getStream(int streamId)
getStream
in interface Session
streamId
- the id of the stream to retrieveSession.getStreams()
public Object getAttribute(String key)
getAttribute
in interface Session
key
- the attribute keySession.setAttribute(String, Object)
public void setAttribute(String key, Object value)
setAttribute
in interface Session
key
- the attribute keyvalue
- an arbitrary object to associate with the given key to this sessionSession.getAttribute(String)
,
Session.removeAttribute(String)
public Object removeAttribute(String key)
removeAttribute
in interface Session
key
- the attribute keySession.setAttribute(String, Object)
public void onControlFrame(ControlFrame frame)
onControlFrame
in interface Parser.Listener
public void onDataFrame(DataFrame frame, ByteBuffer data)
onDataFrame
in interface Parser.Listener
public void onStreamException(StreamException x)
onStreamException
in interface Parser.Listener
public void onSessionException(SessionException x)
onSessionException
in interface Parser.Listener
protected void close()
public <C> void control(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Handler<C> handler, C context)
public <C> void data(IStream stream, DataInfo dataInfo, long timeout, TimeUnit unit, Handler<C> handler, C context)
public void flush()
ISession
Initiates the flush of data to the other peer.
Note that the flush may do nothing if, for example, there is nothing to flush, or if the data to be flushed belong to streams that have their flow-control stalled.
public void completed(StandardSession.FrameBytes frameBytes)
Handler
Callback invoked when the operation completes.
completed
in interface Handler<StandardSession.FrameBytes>
frameBytes
- the contextHandler.failed(Object, Throwable)
public void failed(StandardSession.FrameBytes frameBytes, Throwable x)
Handler
Callback invoked when the operation fails.
failed
in interface Handler<StandardSession.FrameBytes>
frameBytes
- the contextx
- the reason for the operation failureprotected void write(ByteBuffer buffer, Handler<StandardSession.FrameBytes> handler, StandardSession.FrameBytes frameBytes)
public int getWindowSize()
public void setWindowSize(int initialWindowSize)
public void dump(Appendable out, String indent) throws IOException
dump
in interface Dumpable
IOException
Copyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.