下面列出了怎么用org.springframework.web.socket.sockjs.transport.SockJsServiceConfig的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Create a new instance.
* @param id the session ID
* @param config the SockJS service configuration options
* @param handler the recipient of SockJS messages
* @param attributes attributes from the HTTP handshake to associate with the WebSocket
* session; the provided attributes are copied, the original map is not used.
*/
public AbstractSockJsSession(String id, SockJsServiceConfig config, WebSocketHandler handler,
@Nullable Map<String, Object> attributes) {
Assert.notNull(id, "Session id must not be null");
Assert.notNull(config, "SockJsServiceConfig must not be null");
Assert.notNull(handler, "WebSocketHandler must not be null");
this.id = id;
this.config = config;
this.handler = handler;
if (attributes != null) {
this.attributes.putAll(attributes);
}
}
/**
* Create a new instance.
* @param id the session ID
* @param config the SockJS service configuration options
* @param handler the recipient of SockJS messages
* @param attributes attributes from the HTTP handshake to associate with the WebSocket
* session; the provided attributes are copied, the original map is not used.
*/
public AbstractSockJsSession(String id, SockJsServiceConfig config, WebSocketHandler handler,
@Nullable Map<String, Object> attributes) {
Assert.notNull(id, "Session id must not be null");
Assert.notNull(config, "SockJsServiceConfig must not be null");
Assert.notNull(handler, "WebSocketHandler must not be null");
this.id = id;
this.config = config;
this.handler = handler;
if (attributes != null) {
this.attributes.putAll(attributes);
}
}
/**
* Create a new instance.
* @param id the session ID
* @param config SockJS service configuration options
* @param handler the recipient of SockJS messages
* @param attributes attributes from the HTTP handshake to associate with the WebSocket
* session; the provided attributes are copied, the original map is not used.
*/
public AbstractSockJsSession(String id, SockJsServiceConfig config, WebSocketHandler handler,
Map<String, Object> attributes) {
Assert.notNull(id, "SessionId must not be null");
Assert.notNull(config, "SockJsConfig must not be null");
Assert.notNull(handler, "WebSocketHandler must not be null");
this.id = id;
this.config = config;
this.handler = handler;
if (attributes != null) {
this.attributes.putAll(attributes);
}
}
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler,
WebSocketServerSockJsSession sockJsSession) {
Assert.notNull(serviceConfig, "serviceConfig must not be null");
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
Assert.notNull(sockJsSession, "session must not be null");
this.sockJsServiceConfig = serviceConfig;
this.sockJsSession = sockJsSession;
webSocketHandler = WebSocketHandlerDecorator.unwrap(webSocketHandler);
this.subProtocols = ((webSocketHandler instanceof SubProtocolCapable) ?
new ArrayList<>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : Collections.emptyList());
}
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler,
WebSocketServerSockJsSession sockJsSession) {
Assert.notNull(serviceConfig, "serviceConfig must not be null");
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
Assert.notNull(sockJsSession, "session must not be null");
this.sockJsServiceConfig = serviceConfig;
this.sockJsSession = sockJsSession;
webSocketHandler = WebSocketHandlerDecorator.unwrap(webSocketHandler);
this.subProtocols = ((webSocketHandler instanceof SubProtocolCapable) ?
new ArrayList<>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : Collections.emptyList());
}
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler,
WebSocketServerSockJsSession sockJsSession) {
Assert.notNull(serviceConfig, "serviceConfig must not be null");
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
Assert.notNull(sockJsSession, "session must not be null");
this.sockJsServiceConfig = serviceConfig;
this.sockJsSession = sockJsSession;
webSocketHandler = WebSocketHandlerDecorator.unwrap(webSocketHandler);
this.subProtocols = ((webSocketHandler instanceof SubProtocolCapable) ?
new ArrayList<String>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : null);
}
public SockJsServiceConfig getSockJsServiceConfig() {
return this.config;
}
public PollingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
public AbstractHttpSockJsSession(String id, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(id, config, wsHandler, attributes);
this.messageCache = new LinkedBlockingQueue<>(config.getHttpMessageCacheSize());
}
public WebSocketServerSockJsSession(String id, SockJsServiceConfig config,
WebSocketHandler handler, @Nullable Map<String, Object> attributes) {
super(id, config, handler, attributes);
}
public StreamingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
protected SockJsServiceConfig getSockJsConfig() {
return this.sockJsServiceConfig;
}
public HtmlFileStreamingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
@Override
public void initialize(SockJsServiceConfig serviceConfig) {
this.serviceConfig = serviceConfig;
}
public SockJsServiceConfig getServiceConfig() {
Assert.state(this.serviceConfig != null, "No SockJsServiceConfig available");
return this.serviceConfig;
}
public EventSourceStreamingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
public XhrStreamingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
public TestAbstractHttpSockJsSession(SockJsServiceConfig config, WebSocketHandler handler,
Map<String, Object> attributes) {
super("1", config, handler, attributes);
}
public TestHttpSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
public TestWebSocketServerSockJsSession(SockJsServiceConfig config, WebSocketHandler handler,
Map<String, Object> attributes) {
super("1", config, handler, attributes);
}
public TestSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
public SockJsServiceConfig getSockJsServiceConfig() {
return this.config;
}
public PollingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
public AbstractHttpSockJsSession(String id, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(id, config, wsHandler, attributes);
this.messageCache = new LinkedBlockingQueue<>(config.getHttpMessageCacheSize());
}
public WebSocketServerSockJsSession(String id, SockJsServiceConfig config,
WebSocketHandler handler, @Nullable Map<String, Object> attributes) {
super(id, config, handler, attributes);
}
public StreamingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
protected SockJsServiceConfig getSockJsConfig() {
return this.sockJsServiceConfig;
}
public HtmlFileStreamingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(sessionId, config, wsHandler, attributes);
}
@Override
public void initialize(SockJsServiceConfig serviceConfig) {
this.serviceConfig = serviceConfig;
}
public SockJsServiceConfig getServiceConfig() {
Assert.state(this.serviceConfig != null, "No SockJsServiceConfig available");
return this.serviceConfig;
}