Class SockJsFrame

java.lang.Object
org.springframework.web.socket.sockjs.frame.SockJsFrame

public class SockJsFrame extends Object
Represents a SockJS frame. Provides factory methods to create SockJS frames.
Since:
4.0
Author:
Rossen Stoyanchev
  • Field Details

    • CHARSET

      public static final Charset CHARSET
      The charset used by SockJS.
  • Constructor Details

    • SockJsFrame

      public SockJsFrame(String content)
      Create a new instance frame with the given frame content.
      Parameters:
      content - the content (must be a non-empty and represent a valid SockJS frame)
  • Method Details

    • getType

      public SockJsFrameType getType()
      Return the SockJS frame type.
    • getContent

      public String getContent()
      Return the SockJS frame content (never null).
    • getContentBytes

      public byte[] getContentBytes()
      Return the SockJS frame content as a byte array.
    • getFrameData

      @Nullable public String getFrameData()
      Return data contained in a SockJS "message" and "close" frames. Otherwise for SockJS "open" and "close" frames, which do not contain data, return null.
    • equals

      public boolean equals(@Nullable Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • openFrame

      public static SockJsFrame openFrame()
    • heartbeatFrame

      public static SockJsFrame heartbeatFrame()
    • messageFrame

      public static SockJsFrame messageFrame(SockJsMessageCodec codec, String... messages)
    • closeFrameGoAway

      public static SockJsFrame closeFrameGoAway()
    • closeFrameAnotherConnectionOpen

      public static SockJsFrame closeFrameAnotherConnectionOpen()
    • closeFrame

      public static SockJsFrame closeFrame(int code, @Nullable String reason)