Class ProtocolHandler

java.lang.Object
org.glassfish.tyrus.core.ProtocolHandler

public final class ProtocolHandler extends Object
Tyrus protocol handler.

Responsible for framing and unframing raw websocket frames. Tyrus creates exactly one instance per Session.

  • Field Details

  • Method Details

    • setWriter

      public void setWriter(Writer writer)
      Set Writer 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 received UpgradeRequest.
    • setExtensions

      public void setExtensions(List<Extension> extensions)
      Client side. Set extensions negotiated for this WebSocket session/connection.
      Parameters:
      extensions - list of negotiated extensions. Can be null.
    • 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 Future<Frame> send(byte[] data)
      Deprecated.
    • send

      public 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 Future<Frame> send(String data)
      Deprecated.
    • send

      public Future<Frame> send(String data, WriterInfo writerInfo)
    • send

      @Deprecated public void send(String data, SendHandler handler)
      Deprecated.
    • send

      public void send(String data, SendHandler handler, WriterInfo writerInfo)
    • sendRawFrame

      public Future<Frame> sendRawFrame(ByteBuffer data)
      Raw frame is always whole (not partial).
      Parameters:
      data - serialized frame.
      Returns:
      send future.
    • stream

      @Deprecated public Future<Frame> stream(boolean last, byte[] bytes, int off, int len)
      Deprecated.
    • stream

      public Future<Frame> stream(boolean last, byte[] bytes, int off, int len, WriterInfo writerInfo)
    • stream

      @Deprecated public Future<Frame> stream(boolean last, String fragment)
      Deprecated.
    • stream

      public Future<Frame> stream(boolean last, String fragment, WriterInfo writerInfo)
    • close

      public Future<Frame> close(int code, String reason)
    • unframe

      public Frame unframe(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.