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.util.List; 020 021import org.springframework.util.concurrent.ListenableFuture; 022import org.springframework.web.socket.WebSocketHandler; 023import org.springframework.web.socket.WebSocketSession; 024import org.springframework.web.socket.sockjs.transport.TransportType; 025 026/** 027 * A client-side implementation for a SockJS transport. 028 * 029 * @author Rossen Stoyanchev 030 * @since 4.1 031 */ 032public interface Transport { 033 034 /** 035 * Return the SockJS transport types that this transport can be used for. 036 * In particular since from a client perspective there is no difference 037 * between XHR and XHR streaming, an {@code XhrTransport} could do both. 038 */ 039 List<TransportType> getTransportTypes(); 040 041 /** 042 * Connect the transport. 043 * @param request the transport request. 044 * @param webSocketHandler the application handler to delegate lifecycle events to. 045 * @return a future to indicate success or failure to connect. 046 */ 047 ListenableFuture<WebSocketSession> connect(TransportRequest request, WebSocketHandler webSocketHandler); 048 049}