Package ratpack.sse

Interface ServerSentEvent

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface ServerSentEvent
    extends java.lang.AutoCloseable
    A server sent event.

    This object maintains references to several bytebufs. Releasing this object releases each held buffer.

    Since:
    1.10
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      static ServerSentEventBuilder builder()
      Creates a builder for an event.
      void close()
      Releases all the buffers held by this event.
      java.util.List<io.netty.buffer.ByteBuf> getComment()
      The “comment” value of the event.
      default java.lang.String getCommentAsString()
      The “comment” value of the event.
      java.util.List<io.netty.buffer.ByteBuf> getData()
      The “data” value of the event.
      default java.lang.String getDataAsString()
      The “data” value of the event.
      io.netty.buffer.ByteBuf getEvent()
      The “event” value of the event.
      default java.lang.String getEventAsString()
      The “event” value of the event.
      io.netty.buffer.ByteBuf getId()
      The “id” value of the event.
      default java.lang.String getIdAsString()
      The “id” value of the event.
      static io.netty.buffer.ByteBuf join​(java.util.List<io.netty.buffer.ByteBuf> lines)
      Joins a list of byte buf lines to a single byte buf.
    • Method Detail

      • builder

        static ServerSentEventBuilder builder()
        Creates a builder for an event.
        Returns:
        a builder for an event
      • getId

        io.netty.buffer.ByteBuf getId()
        The “id” value of the event.
        Returns:
        the “id” value of the event
      • getIdAsString

        default java.lang.String getIdAsString()
        The “id” value of the event.
        Returns:
        the “id” value of the event
      • getEvent

        io.netty.buffer.ByteBuf getEvent()
        The “event” value of the event.
        Returns:
        the “event” value of the event
      • getEventAsString

        default java.lang.String getEventAsString()
        The “event” value of the event.
        Returns:
        the “event” value of the event
      • getData

        java.util.List<io.netty.buffer.ByteBuf> getData()
        The “data” value of the event.

        Each list element corresponds to a line of data.

        Returns:
        the “data” value of the event
      • getDataAsString

        default java.lang.String getDataAsString()
        The “data” value of the event.

        Returns:
        the “data” value of the event
      • getComment

        java.util.List<io.netty.buffer.ByteBuf> getComment()
        The “comment” value of the event.
        Returns:
        the “comment” value of the event
      • getCommentAsString

        default java.lang.String getCommentAsString()
        The “comment” value of the event.

        Each list element corresponds to a line of data.

        Returns:
        the “comment” value of the event
      • join

        static io.netty.buffer.ByteBuf join​(java.util.List<io.netty.buffer.ByteBuf> lines)
        Joins a list of byte buf lines to a single byte buf.

        Can be used with getData() or getComment() to obtain the multi-line value.

        Parameters:
        lines - a list of UTF-8 lines
        Returns:
        a new byte buffer of the lines joined with a newline
      • close

        void close()
        Releases all the buffers held by this event.

        This must be called exactly once for each event.

        Specified by:
        close in interface java.lang.AutoCloseable