Package org.glassfish.tyrus.core
Class ProtocolHandler
- java.lang.Object
-
- org.glassfish.tyrus.core.ProtocolHandler
-
public final class ProtocolHandler extends java.lang.Object
Tyrus protocol handler.Responsible for framing and unframing raw websocket frames. Tyrus creates exactly one instance per Session.
-
-
Field Summary
Fields Modifier and Type Field Description static int
MASK_SIZE
RFC 6455
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.concurrent.Future<Frame>
close(int code, java.lang.String reason)
Handshake
handshake(TyrusEndpointWrapper endpointWrapper, UpgradeRequest request, UpgradeResponse response, ExtendedExtension.ExtensionContext extensionContext)
Server side handshake processing.boolean
hasExtensions()
Returns true when current connection has some negotiated extension.void
process(Frame frame, TyrusWebSocket socket)
TODO.java.util.concurrent.Future<Frame>
send(byte[] data)
Deprecated.void
send(byte[] data, SendHandler handler)
Deprecated.void
send(byte[] data, SendHandler handler, WriterInfo writerInfo)
java.util.concurrent.Future<Frame>
send(byte[] data, WriterInfo writerInfo)
java.util.concurrent.Future<Frame>
send(java.lang.String data)
Deprecated.void
send(java.lang.String data, SendHandler handler)
Deprecated.void
send(java.lang.String data, SendHandler handler, WriterInfo writerInfo)
java.util.concurrent.Future<Frame>
send(java.lang.String data, WriterInfo writerInfo)
java.util.concurrent.Future<Frame>
sendRawFrame(java.nio.ByteBuffer data)
Raw frame is always whole (not partial).void
setExtensionContext(ExtendedExtension.ExtensionContext extensionContext)
Client side.void
setExtensions(java.util.List<Extension> extensions)
Client side.void
setMessageEventListener(MessageEventListener messageEventListener)
Set message event listener.void
setWebSocket(TyrusWebSocket webSocket)
Client side.void
setWriter(Writer writer)
SetWriter
instance.java.util.concurrent.Future<Frame>
stream(boolean last, byte[] bytes, int off, int len)
Deprecated.java.util.concurrent.Future<Frame>
stream(boolean last, byte[] bytes, int off, int len, WriterInfo writerInfo)
java.util.concurrent.Future<Frame>
stream(boolean last, java.lang.String fragment)
Deprecated.java.util.concurrent.Future<Frame>
stream(boolean last, java.lang.String fragment, WriterInfo writerInfo)
Frame
unframe(java.nio.ByteBuffer buffer)
TODO!
-
-
-
Field Detail
-
MASK_SIZE
public static final int MASK_SIZE
RFC 6455- See Also:
- Constant Field Values
-
-
Method Detail
-
setWriter
public void setWriter(Writer writer)
SetWriter
instance.The set instance is used for "sending" all outgoing WebSocket frames.
- Parameters:
writer
-Writer
to be set.
-
hasExtensions
public boolean hasExtensions()
Returns true when current connection has some negotiated extension.- Returns:
true
if there is at least one negotiated extension associated to this connection,false
otherwise.
-
handshake
public Handshake handshake(TyrusEndpointWrapper endpointWrapper, UpgradeRequest request, UpgradeResponse response, ExtendedExtension.ExtensionContext extensionContext) throws HandshakeException
Server side handshake processing.- Parameters:
endpointWrapper
- endpoint related to the handshake (path is already matched).request
- handshake request.response
- handshake response.extensionContext
- extension context.- Returns:
- server handshake object.
- Throws:
HandshakeException
- when there is problem with receivedUpgradeRequest
.
-
setExtensions
public void setExtensions(java.util.List<Extension> extensions)
Client side. Set extensions negotiated for this WebSocket session/connection.- Parameters:
extensions
- list of negotiated extensions. Can benull
.
-
setWebSocket
public void setWebSocket(TyrusWebSocket webSocket)
Client side. Set WebSocket.- Parameters:
webSocket
- client WebSocket connection.
-
setExtensionContext
public void setExtensionContext(ExtendedExtension.ExtensionContext extensionContext)
Client side. Set extension context.- Parameters:
extensionContext
- extension context.
-
setMessageEventListener
public void setMessageEventListener(MessageEventListener messageEventListener)
Set message event listener.- Parameters:
messageEventListener
- message event listener.
-
send
@Deprecated public java.util.concurrent.Future<Frame> send(byte[] data)
Deprecated.
-
send
public java.util.concurrent.Future<Frame> send(byte[] data, WriterInfo writerInfo)
-
send
@Deprecated public void send(byte[] data, SendHandler handler)
Deprecated.
-
send
public void send(byte[] data, SendHandler handler, WriterInfo writerInfo)
-
send
@Deprecated public java.util.concurrent.Future<Frame> send(java.lang.String data)
Deprecated.
-
send
public java.util.concurrent.Future<Frame> send(java.lang.String data, WriterInfo writerInfo)
-
send
@Deprecated public void send(java.lang.String data, SendHandler handler)
Deprecated.
-
send
public void send(java.lang.String data, SendHandler handler, WriterInfo writerInfo)
-
sendRawFrame
public java.util.concurrent.Future<Frame> sendRawFrame(java.nio.ByteBuffer data)
Raw frame is always whole (not partial).- Parameters:
data
- serialized frame.- Returns:
- send future.
-
stream
@Deprecated public java.util.concurrent.Future<Frame> stream(boolean last, byte[] bytes, int off, int len)
Deprecated.
-
stream
public java.util.concurrent.Future<Frame> stream(boolean last, byte[] bytes, int off, int len, WriterInfo writerInfo)
-
stream
@Deprecated public java.util.concurrent.Future<Frame> stream(boolean last, java.lang.String fragment)
Deprecated.
-
stream
public java.util.concurrent.Future<Frame> stream(boolean last, java.lang.String fragment, WriterInfo writerInfo)
-
close
public java.util.concurrent.Future<Frame> close(int code, java.lang.String reason)
-
unframe
public Frame unframe(java.nio.ByteBuffer buffer)
TODO!- Parameters:
buffer
- TODO.- Returns:
- TODO.
-
process
public void process(Frame frame, TyrusWebSocket socket)
TODO.called after Extension execution.
validates frame + processes its content
- Parameters:
frame
- TODO.socket
- TODO.
-
-