Top Description Methods
org.springframework.web.socket.sockjs.frame

public Interface SockJsMessageCodec

Known Direct Implementers
org.springframework.web.socket.sockjs.frame.AbstractSockJsMessageCodec
Imports
java.io.IOException, .InputStream, org.springframework.lang.Nullable

Encode and decode messages to and from a SockJS message frame, essentially an array of JSON-encoded messages. For example:
a["message1","message2"]
Author
Rossen Stoyanchev
Since
4.0

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

an array of messages, or null if none
decode
(String
the SockJS message frame
content
)

Decode the given SockJS message frame.

public String[]

Returns:

an array of messages, or null if none
decodeInputStream
(InputStream
the SockJS message frame
content
)

Decode the given SockJS message frame.

public String

Returns:

the content for a SockJS message frame (never null)
encode
(String...
the messages to encode
messages
)

Encode the given messages as a SockJS message frame.

Method Detail

decodeback to summary
public String[] decode(String content) throws IOException

Decode the given SockJS message frame.

Parameters
content:String

the SockJS message frame

Returns:String[]

an array of messages, or null if none

Annotations
@Nullable
Exceptions
IOException:
if the content could not be parsed
decodeInputStreamback to summary
public String[] decodeInputStream(InputStream content) throws IOException

Decode the given SockJS message frame.

Parameters
content:InputStream

the SockJS message frame

Returns:String[]

an array of messages, or null if none

Annotations
@Nullable
Exceptions
IOException:
if the content could not be parsed
encodeback to summary
public String encode(String... messages)

Encode the given messages as a SockJS message frame. Aside from applying standard JSON quoting to each message, there are some additional JSON Unicode escaping rules. See the "JSON Unicode Encoding" section of SockJS protocol (i.e. the protocol test suite).

Parameters
messages:String[]

the messages to encode

Returns:String

the content for a SockJS message frame (never null)