001/* 002 * Copyright 2002-2015 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.client; 018 019import java.net.URI; 020 021import org.springframework.http.HttpHeaders; 022import org.springframework.web.socket.TextMessage; 023 024/** 025 * A SockJS {@link Transport} that uses HTTP requests to simulate a WebSocket 026 * interaction. The {@code connect} method of the base {@code Transport} interface 027 * is used to receive messages from the server while the 028 * {@link #executeSendRequest} method here is used to send messages. 029 * 030 * @author Rossen Stoyanchev 031 * @since 4.1 032 */ 033public interface XhrTransport extends Transport, InfoReceiver { 034 035 /** 036 * An {@code XhrTransport} supports both the "xhr_streaming" and "xhr" SockJS 037 * server transports. From a client perspective there is no implementation 038 * difference. 039 * <p>By default an {@code XhrTransport} will be used with "xhr_streaming" 040 * first and then with "xhr", if the streaming fails to connect. In some 041 * cases it may be useful to suppress streaming so that only "xhr" is used. 042 */ 043 boolean isXhrStreamingDisabled(); 044 045 /** 046 * Execute a request to send the message to the server. 047 * <p>Note that as of 4.2 this method accepts a {@code headers} parameter. 048 * @param transportUrl the URL for sending messages. 049 * @param message the message to send 050 */ 051 void executeSendRequest(URI transportUrl, HttpHeaders headers, TextMessage message); 052 053}