Class 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.

    • Method Detail

      • 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.
      • 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 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 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

        @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.
      • 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.