Class LocalSessionImpl
- java.lang.Object
-
- org.cometd.common.AbstractClientSession
-
- org.cometd.server.LocalSessionImpl
-
- All Implemented Interfaces:
ClientSession,LocalSession,Session,org.eclipse.jetty.util.component.Dumpable
public class LocalSessionImpl extends AbstractClientSession implements LocalSession
A
LocalSessionimplementation.This
LocalSessionimplementation communicates with itsServerSessioncounterpart without any serialization.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classLocalSessionImpl.LocalChannelA channel scoped to this LocalSession.-
Nested classes/interfaces inherited from class org.cometd.common.AbstractClientSession
AbstractClientSession.AbstractSessionChannel
-
Nested classes/interfaces inherited from interface org.cometd.bayeux.client.ClientSession
ClientSession.Extension, ClientSession.MessageListener
-
-
Constructor Summary
Constructors Constructor Description LocalSessionImpl(BayeuxServerImpl bayeux, java.lang.String idHint)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisconnect(ClientSession.MessageListener callback)Disconnects this session, ending the link between the client and the server peers.java.lang.StringgetId()The clientId of the session.ServerSessiongetServerSession()voidhandshake(java.util.Map<java.lang.String,java.lang.Object> template, ClientSession.MessageListener callback)Initiates the bayeux protocol handshake with the server(s).booleanisConnected()A connected session is a session where the link between the client and the server has been established.booleanisHandshook()A handshook session is a session where the handshake has successfully completedprotected AbstractClientSession.AbstractSessionChannelnewChannel(ChannelId channelId)protected ChannelIdnewChannelId(java.lang.String channelId)protected ServerMessage.MutablenewMessage()voidreceive(Message.Mutable message, Promise<java.lang.Void> promise)Receives a message (from the server) and process it.protected voidsend(Message.Mutable message)protected voidsend(ServerSessionImpl session, ServerMessage.Mutable message)Enqueues or sends a message to the server.protected voidsendBatch()java.lang.StringtoString()-
Methods inherited from class org.cometd.common.AbstractClientSession
addExtension, batch, dump, endBatch, extendIncoming, extendOutgoing, getAttribute, getAttributeNames, getChannel, getChannel, getChannels, getExtensions, isBatching, newMessageId, notifyCallback, notifyListeners, registerCallback, registerSubscriber, remoteCall, removeAttribute, removeExtension, resetSubscriptions, setAttribute, startBatch, unregisterCallback, unregisterSubscriber
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.cometd.bayeux.client.ClientSession
addExtension, disconnect, getChannel, getExtensions, handshake, handshake, remoteCall, removeExtension
-
Methods inherited from interface org.cometd.bayeux.Session
batch, endBatch, getAttribute, getAttributeNames, removeAttribute, setAttribute, startBatch
-
-
-
-
Constructor Detail
-
LocalSessionImpl
public LocalSessionImpl(BayeuxServerImpl bayeux, java.lang.String idHint)
-
-
Method Detail
-
receive
public void receive(Message.Mutable message, Promise<java.lang.Void> promise)
Description copied from class:AbstractClientSessionReceives a message (from the server) and process it.
Processing the message involves calling the receive
extensionsand the channellisteners.- Overrides:
receivein classAbstractClientSession- Parameters:
message- the message received.promise- the promise notified of the receive processing
-
newChannel
protected AbstractClientSession.AbstractSessionChannel newChannel(ChannelId channelId)
- Specified by:
newChannelin classAbstractClientSession
-
newChannelId
protected ChannelId newChannelId(java.lang.String channelId)
- Specified by:
newChannelIdin classAbstractClientSession
-
sendBatch
protected void sendBatch()
- Specified by:
sendBatchin classAbstractClientSession
-
getServerSession
public ServerSession getServerSession()
- Specified by:
getServerSessionin interfaceLocalSession- Returns:
- the associated
ServerSession
-
handshake
public void handshake(java.util.Map<java.lang.String,java.lang.Object> template, ClientSession.MessageListener callback)Description copied from interface:ClientSessionInitiates the bayeux protocol handshake with the server(s).
The handshake initiated by this method is asynchronous and does not wait for the handshake response.
- Specified by:
handshakein interfaceClientSession- Parameters:
template- additional fields to add to the handshake message.callback- the message listener to notify of the handshake result
-
disconnect
public void disconnect(ClientSession.MessageListener callback)
Description copied from interface:ClientSessionDisconnects this session, ending the link between the client and the server peers.
- Specified by:
disconnectin interfaceClientSession- Parameters:
callback- the message listener to notify of the disconnect result
-
getId
public java.lang.String getId()
Description copied from interface:SessionThe clientId of the session.
This would more correctly be called a "sessionId", but for backwards compatibility with the Bayeux protocol, it is a field called "clientId" that identifies a session.
-
isConnected
public boolean isConnected()
Description copied from interface:SessionA connected session is a session where the link between the client and the server has been established.
- Specified by:
isConnectedin interfaceSession- Returns:
- whether the session is connected
- See Also:
Session.disconnect()
-
isHandshook
public boolean isHandshook()
Description copied from interface:SessionA handshook session is a session where the handshake has successfully completed
- Specified by:
isHandshookin interfaceSession- Returns:
- whether the session is handshook
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
send
protected void send(Message.Mutable message)
- Specified by:
sendin classAbstractClientSession
-
send
protected void send(ServerSessionImpl session, ServerMessage.Mutable message)
Enqueues or sends a message to the server.
This method will either enqueue the message, if this session
is batching, or perform the send immediately.- Parameters:
session- The ServerSession to send as. This normally the current server session, but during handshake it is a proposed server session.message- The message to send.
-
newMessage
protected ServerMessage.Mutable newMessage()
- Overrides:
newMessagein classAbstractClientSession
-
-