public abstract class AbstractSockJsSession extends ObjectSE implements SockJsSession
SockJsSession
を実装する SockJS セッションの抽象基本クラス。修飾子と型 | フィールドと説明 |
---|---|
static StringSE | DISCONNECTED_CLIENT_LOG_CATEGORY クライアントが去った後にネットワーク IO 例外で使用するログカテゴリ。 |
protected static Log | disconnectedClientLogger クライアントが去った後、ネットワーク IO 障害で使用する別のロガー。 |
protected Log | logger |
protected ObjectSE | responseLock |
コンストラクターと説明 |
---|
AbstractSockJsSession(StringSE id, SockJsServiceConfig config, WebSocketHandler handler, MapSE<StringSE, ObjectSE> attributes) 新しいインスタンスを作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
protected void | cancelHeartbeat() |
void | close() クリーンアップを実行し、 WebSocketHandler に通知します。 |
void | close(CloseStatus status) クリーンアップを実行し、 WebSocketHandler に通知します。 |
void | delegateConnectionClosed(CloseStatus status) 基本となる接続が閉じられたときに呼び出されます。 |
void | delegateConnectionEstablished() |
void | delegateError(ThrowableSE ex) |
void | delegateMessages(StringSE... messages) |
void | disableHeartbeat() SockJS ハートビートを無効にします。これは、おそらく上位レベルのプロトコルですでにセッションに対してハートビートが有効になっているためです。 |
protected abstract void | disconnect(CloseStatus status) 実際に基になる WebSocket セッションを閉じるか、HTTP トランスポートの場合は基になるリクエストを完了します。 |
MapSE<StringSE, ObjectSE> | getAttributes() WebSocket セッションに関連付けられた属性を持つマップを返します。 |
StringSE | getId() 一意のセッション識別子を返します。 |
protected SockJsMessageCodec | getMessageCodec() |
SockJsServiceConfig | getSockJsServiceConfig() |
long | getTimeSinceLastActive() セッションが最後にアクティブになってからの時間(ミリ秒単位)を返します。セッションが新しい場合は、セッションが作成されてからの時間を返します。 |
abstract boolean | isActive() ポーリングセッションとストリーミングセッションは、定期的に現在の HTTP リクエストを閉じ、次のリクエストが送信されるのを待ちます。 |
boolean | isClosed() |
boolean | isNew() |
boolean | isOpen() 基になる接続が開いているかどうか。 |
protected void | scheduleHeartbeat() |
protected void | sendHeartbeat() |
void | sendMessage(WebSocketMessage<?> message) WebSocket メッセージを送信する: TextMessage または BinaryMessage のいずれか。 |
protected abstract void | sendMessageInternal(StringSE message) |
StringSE | toString() |
void | tryCloseWithSockJsTransportError(ThrowableSE error, CloseStatus closeStatus) SockJS トランスポートの処理に起因するエラーのため、終了します。 |
protected void | updateLastActiveTime() セッションが非アクティブになるたびに呼び出されます。 |
protected void | writeFrame(SockJsFrame frame) TransportHandler および(TransportHandler 固有の)セッションクラス内で内部的に使用します。 |
protected abstract void | writeFrameInternal(SockJsFrame frame) |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
getAcceptedProtocol, getBinaryMessageSizeLimit, getExtensions, getHandshakeHeaders, getLocalAddress, getPrincipal, getRemoteAddress, getTextMessageSizeLimit, getUri, setBinaryMessageSizeLimit, setTextMessageSizeLimit
public static final StringSE DISCONNECTED_CLIENT_LOG_CATEGORY
サーブレットコンテナーは、クライアントが切断したコールバックを公開しません。eclipse-ee4j/servlet-api#44 を参照してください。クライアントが去ったためにネットワーク IO 障害が発生する可能性があり、不要なスタックトレースでログがいっぱいになる可能性があります。
サーバーごとにこのようなネットワーク障害を特定し、別のログカテゴリに記録するよう最善を尽くしています。完全なスタックトレースが TRACE レベルで表示されている間、単純な 1 行のメッセージがデバッグレベルでログに記録されます。
protected static final Log disconnectedClientLogger
protected final Log logger
protected final ObjectSE responseLock
public AbstractSockJsSession(StringSE id, SockJsServiceConfig config, WebSocketHandler handler, @Nullable MapSE<StringSE,ObjectSE> attributes)
id
- セッション IDconfig
- SockJS サービス構成オプション handler
- SockJS メッセージの受信者 attributes
- WebSocket セッションに関連付ける HTTP ハンドシェイクの属性。提供された属性がコピーされ、元のマップは使用されません。public StringSE getId()
WebSocketSession
WebSocketSession
の getId
protected SockJsMessageCodec getMessageCodec()
public SockJsServiceConfig getSockJsServiceConfig()
public MapSE<StringSE,ObjectSE> getAttributes()
WebSocketSession
サーバー側では、最初に HandshakeInterceptor
を介してマップにデータを入力できます。クライアント側では、WebSocketClient
ハンドシェイクメソッドを介してマップにデータを入力できます。
WebSocketSession
の getAttributes
null
)public final void sendMessage(WebSocketMessage<?> message) throws IOExceptionSE
WebSocketSession
TextMessage
または BinaryMessage
のいずれか。 注意 : 基礎となる標準 WebSocket セッション(JSR-356)は同時送信を許可しません。送信を同期する必要があります。これを確実にするための 1 つのオプションは、WebSocketSession
を ConcurrentWebSocketSessionDecorator
でラップすることです。
WebSocketSession
の sendMessage
IOExceptionSE
ConcurrentWebSocketSessionDecorator
protected abstract void sendMessageInternal(StringSE message) throws IOExceptionSE
public boolean isNew()
public boolean isOpen()
WebSocketSession
WebSocketSession
の isOpen
public boolean isClosed()
public final void close() throws IOExceptionSE
WebSocketHandler
に通知します。CloseableSE
の closeSE
AutoCloseableSE
の closeSE
WebSocketSession
の close
IOExceptionSE
public final void close(CloseStatus status) throws IOExceptionSE
WebSocketHandler
に通知します。WebSocketSession
の close
IOExceptionSE
public long getTimeSinceLastActive()
SockJsSession
SockJsSession
の getTimeSinceLastActive
protected void updateLastActiveTime()
public void disableHeartbeat()
SockJsSession
SockJsSession
の disableHeartbeat
protected void sendHeartbeat() throws SockJsTransportFailureException
protected void scheduleHeartbeat()
protected void cancelHeartbeat()
public abstract boolean isActive()
protected abstract void disconnect(CloseStatus status) throws IOExceptionSE
protected void writeFrame(SockJsFrame frame) throws SockJsTransportFailureException
protected abstract void writeFrameInternal(SockJsFrame frame) throws IOExceptionSE
public void delegateConnectionEstablished() throws ExceptionSE
ExceptionSE
public void delegateMessages(StringSE... messages) throws SockJsMessageDeliveryException
public final void delegateConnectionClosed(CloseStatus status) throws ExceptionSE
ExceptionSE
public void tryCloseWithSockJsTransportError(ThrowableSE error, CloseStatus closeStatus)
public void delegateError(ThrowableSE ex) throws ExceptionSE
ExceptionSE
public StringSE toString()
ObjectSE
の toStringSE