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

public abstract Class AbstractSockJsMessageCodec

extends Object
implements SockJsMessageCodec
Class Inheritance
All Implemented Interfaces
org.springframework.web.socket.sockjs.frame.SockJsMessageCodec
Known Direct Subclasses
org.springframework.web.socket.sockjs.frame.Jackson2SockJsMessageCodec
Imports
org.springframework.util.Assert

A base class for SockJS message codec that provides an implementation of encode(String[]).
Author
Rossen Stoyanchev
Since
4.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract char[]
applyJsonQuoting(String content)

Apply standard JSON string quoting (see json.org).

public String
encode(String...
the messages to encode
messages
)

Implements org.springframework.web.socket.sockjs.frame.SockJsMessageCodec.encode.

Encode the given messages as a SockJS message frame.

private String
escapeSockJsSpecialChars(char[] characters)

See "JSON Unicode Encoding" section of SockJS protocol.

private boolean
isSockJsSpecialChar(char ch)

See `escapable_by_server` variable in the SockJS protocol test suite.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AbstractSockJsMessageCodecback to summary
public AbstractSockJsMessageCodec()

Method Detail

applyJsonQuotingback to summary
protected abstract char[] applyJsonQuoting(String content)

Apply standard JSON string quoting (see json.org).

encodeback to summary
public String encode(String... messages)

Implements org.springframework.web.socket.sockjs.frame.SockJsMessageCodec.encode.

Doc from org.springframework.web.socket.sockjs.frame.SockJsMessageCodec.encode.

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)

Annotations
@Override
escapeSockJsSpecialCharsback to summary
private String escapeSockJsSpecialChars(char[] characters)

See "JSON Unicode Encoding" section of SockJS protocol.

isSockJsSpecialCharback to summary
private boolean isSockJsSpecialChar(char ch)

See `escapable_by_server` variable in the SockJS protocol test suite.