org.springframework.web.socket.sockjs.frame

## 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 Summary

Fields
`static Charset` `CHARSET` The charset used by SockJS.

### Constructor Summary

Constructors
Constructor and Description
`SockJsFrame(String content)` Create a new instance frame with the given frame content.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static SockJsFrame` `closeFrame(int code, String reason)`
`static SockJsFrame` `closeFrameAnotherConnectionOpen()`
`static SockJsFrame` `closeFrameGoAway()`
`boolean` `equals(Object other)`
`String` `getContent()` Return the SockJS frame content (never `null`).
`byte[]` `getContentBytes()` Return the SockJS frame content as a byte array.
`String` `getFrameData()` Return data contained in a SockJS "message" and "close" frames.
`SockJsFrameType` `getType()` Return the SockJS frame type.
`int` `hashCode()`
`static SockJsFrame` `heartbeatFrame()`
`static SockJsFrame` `messageFrame(SockJsMessageCodec codec, String... messages)`
`static SockJsFrame` `openFrame()`
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### CHARSET

    public static final Charset CHARSET

The charset used by SockJS.

### Constructor Detail

#### 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 Detail

#### 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)