org.cometd.bayeux.server
Interface ServerSession

All Superinterfaces:
Session

public interface ServerSession
extends Session

Objects implementing this interface are the server-side representation of remote Bayeux clients.

ServerSession contains the queue of messages to be delivered to the client; messages are normally queued on a ServerSession by publishing them to a channel to which the session is subscribed (via ServerChannel.publish(Session, ServerMessage)).

The deliver(Session, ServerMessage) and deliver(Session, String, Object, String) methods may be used to directly queue messages to a session without publishing them to all subscribers of a channel.

Version:
$Revision: 1483 $ $Date: 2009-03-04 14:56:47 +0100 (Wed, 04 Mar 2009) $

Nested Class Summary
static interface ServerSession.DeQueueListener
          Listeners objects that implement this interface will be notified when the session queue is being drained to actually deliver the messages.
static interface ServerSession.Extension
          Extension API for ServerSession.
static interface ServerSession.MaxQueueListener
          Listeners objects that implement this interface will be notified when the session queue is full.
static interface ServerSession.MessageListener
          Listeners objects that implement this interface will be notified of message arrival.
static interface ServerSession.RemoveListener
          Listeners objects that implement this interface will be notified of session removal.
static interface ServerSession.ServerSessionListener
          Common interface for ServerSession listeners.
 
Method Summary
 void addExtension(ServerSession.Extension extension)
          Adds the given extension to this session.
 void addListener(ServerSession.ServerSessionListener listener)
          Adds the given listener to this session.
 void deliver(Session from, ServerMessage message)
          Delivers the given message to this session.
 void deliver(Session from, String channel, Object data, String id)
          Delivers the given information to this session.
 LocalSession getLocalSession()
           
 String getUserAgent()
          Get the clients user agent
 boolean isLocalSession()
           
 void removeExtension(ServerSession.Extension extension)
          Removes the given extension from this session
 void removeListener(ServerSession.ServerSessionListener listener)
          Removes the given listener from this session.
 
Methods inherited from interface org.cometd.bayeux.Session
batch, disconnect, endBatch, getAttribute, getAttributeNames, getId, isConnected, isHandshook, removeAttribute, setAttribute, startBatch
 

Method Detail

addExtension

void addExtension(ServerSession.Extension extension)
Adds the given extension to this session.

Parameters:
extension - the extension to add
See Also:
removeExtension(Extension)

removeExtension

void removeExtension(ServerSession.Extension extension)
Removes the given extension from this session

Parameters:
extension - the extension to remove
See Also:
addExtension(Extension)

addListener

void addListener(ServerSession.ServerSessionListener listener)
Adds the given listener to this session.

Parameters:
listener - the listener to add
See Also:
removeListener(ServerSessionListener)

removeListener

void removeListener(ServerSession.ServerSessionListener listener)
Removes the given listener from this session.

Parameters:
listener - the listener to remove
See Also:
addListener(ServerSessionListener)

isLocalSession

boolean isLocalSession()
Returns:
whether this is a session for a local client on server-side

getLocalSession

LocalSession getLocalSession()
Returns:
the LocalSession associated with this session, or null if this is a session representing a remote client.

deliver

void deliver(Session from,
             ServerMessage message)

Delivers the given message to this session.

This is different from ServerChannel.publish(Session, ServerMessage) as the message is delivered only to this session and not to all subscribers of the channel.

The message should still have a channel id specified, so that the ClientSession may identify the listeners the message should be delivered to.

Parameters:
from - the session delivering the message
message - the message to deliver
See Also:
deliver(Session, String, Object, String)

deliver

void deliver(Session from,
             String channel,
             Object data,
             String id)

Delivers the given information to this session.

Parameters:
from - the session delivering the message
channel - the channel of the message
data - the data of the message
id - the id of the message, or null to let the implementation choose an id
See Also:
deliver(Session, ServerMessage)

getUserAgent

String getUserAgent()

Get the clients user agent

Returns:
The string indicating the client user agent, or null if not known


Copyright © 2008-2010 Dojo Foundation. All Rights Reserved.