public class LocalSessionImpl extends AbstractClientSession implements LocalSession
A LocalSession
implementation.
This LocalSession
implementation communicates with its
ServerSession
counterpart without any serialization.
Modifier and Type | Class and Description |
---|---|
protected class |
LocalSessionImpl.LocalChannel
A channel scoped to this LocalSession.
|
AbstractClientSession.AbstractSessionChannel
ClientSession.Extension, ClientSession.MessageListener
Constructor and Description |
---|
LocalSessionImpl(BayeuxServerImpl bayeux,
String idHint) |
Modifier and Type | Method and Description |
---|---|
void |
disconnect(ClientSession.MessageListener callback)
Disconnects this session, ending the link between the client and the server peers.
|
String |
getId()
The clientId of the session.
|
ServerSession |
getServerSession() |
void |
handshake(Map<String,Object> template,
ClientSession.MessageListener callback)
Initiates the bayeux protocol handshake with the server(s).
|
boolean |
isConnected()
A connected session is a session where the link between the client and the server
has been established.
|
boolean |
isHandshook()
A handshook session is a session where the handshake has successfully completed
|
protected AbstractClientSession.AbstractSessionChannel |
newChannel(ChannelId channelId) |
protected ChannelId |
newChannelId(String channelId) |
protected ServerMessage.Mutable |
newMessage() |
void |
receive(Message.Mutable message,
Promise<Void> promise)
Receives a message (from the server) and process it.
|
protected void |
send(Message.Mutable message) |
protected void |
send(ServerSessionImpl session,
ServerMessage.Mutable message)
Enqueues or sends a message to the server.
|
protected void |
sendBatch() |
String |
toString() |
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addExtension, disconnect, getChannel, getExtensions, handshake, handshake, remoteCall, removeExtension
batch, endBatch, getAttribute, getAttributeNames, removeAttribute, setAttribute, startBatch
public LocalSessionImpl(BayeuxServerImpl bayeux, String idHint)
public void receive(Message.Mutable message, Promise<Void> promise)
AbstractClientSession
Receives a message (from the server) and process it.
Processing the message involves calling the receive extensions
and the channel listeners
.
receive
in class AbstractClientSession
message
- the message received.promise
- the promise notified of the receive processingprotected AbstractClientSession.AbstractSessionChannel newChannel(ChannelId channelId)
newChannel
in class AbstractClientSession
protected ChannelId newChannelId(String channelId)
newChannelId
in class AbstractClientSession
protected void sendBatch()
sendBatch
in class AbstractClientSession
public ServerSession getServerSession()
getServerSession
in interface LocalSession
ServerSession
public void handshake(Map<String,Object> template, ClientSession.MessageListener callback)
ClientSession
Initiates the bayeux protocol handshake with the server(s).
The handshake initiated by this method is asynchronous and does not wait for the handshake response.
handshake
in interface ClientSession
template
- additional fields to add to the handshake message.callback
- the message listener to notify of the handshake resultpublic void disconnect(ClientSession.MessageListener callback)
ClientSession
Disconnects this session, ending the link between the client and the server peers.
disconnect
in interface ClientSession
callback
- the message listener to notify of the disconnect resultpublic String getId()
Session
The 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.
public boolean isConnected()
Session
A connected session is a session where the link between the client and the server has been established.
isConnected
in interface Session
Session.disconnect()
public boolean isHandshook()
Session
A handshook session is a session where the handshake has successfully completed
isHandshook
in interface Session
protected void send(Message.Mutable message)
send
in class AbstractClientSession
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.
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.protected ServerMessage.Mutable newMessage()
newMessage
in class AbstractClientSession
Copyright © 2008–2024 The CometD Project. All rights reserved.