001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.socket.sockjs.transport; 018 019import org.springframework.scheduling.TaskScheduler; 020import org.springframework.web.socket.sockjs.SockJsService; 021import org.springframework.web.socket.sockjs.frame.SockJsMessageCodec; 022 023/** 024 * Provides transport handling code with access to the {@link SockJsService} configuration 025 * options they need to have access to. Mainly for internal use. 026 * 027 * @author Rossen Stoyanchev 028 * @since 4.0 029 */ 030public interface SockJsServiceConfig { 031 032 /** 033 * A scheduler instance to use for scheduling heart-beat messages. 034 */ 035 TaskScheduler getTaskScheduler(); 036 037 /** 038 * Streaming transports save responses on the client side and don't free 039 * memory used by delivered messages. Such transports need to recycle the 040 * connection once in a while. This property sets a minimum number of bytes 041 * that can be send over a single HTTP streaming request before it will be 042 * closed. After that client will open a new request. Setting this value to 043 * one effectively disables streaming and will make streaming transports to 044 * behave like polling transports. 045 * <p>The default value is 128K (i.e. 128 * 1024). 046 */ 047 int getStreamBytesLimit(); 048 049 /** 050 * The amount of time in milliseconds when the server has not sent any 051 * messages and after which the server should send a heartbeat frame to the 052 * client in order to keep the connection from breaking. 053 * <p>The default value is 25,000 (25 seconds). 054 */ 055 long getHeartbeatTime(); 056 057 /** 058 * The number of server-to-client messages that a session can cache while waiting for 059 * the next HTTP polling request from the client. All HTTP transports use this 060 * property since even streaming transports recycle HTTP requests periodically. 061 * <p>The amount of time between HTTP requests should be relatively brief and will not 062 * exceed the allows disconnect delay (see 063 * {@link org.springframework.web.socket.sockjs.support.AbstractSockJsService#setDisconnectDelay(long)}, 064 * 5 seconds by default. 065 * <p>The default size is 100. 066 */ 067 int getHttpMessageCacheSize(); 068 069 /** 070 * The codec to use for encoding and decoding SockJS messages. 071 * @throws IllegalStateException if no {@link SockJsMessageCodec} is available 072 */ 073 SockJsMessageCodec getMessageCodec(); 074 075}