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.reactive.socket.server; 018 019import reactor.core.publisher.Mono; 020 021import org.springframework.web.reactive.socket.WebSocketHandler; 022import org.springframework.web.server.ServerWebExchange; 023 024/** 025 * A service to delegate WebSocket-related HTTP requests to. 026 * 027 * <p>For a WebSocket endpoint this means handling the initial WebSocket HTTP 028 * handshake request. For a SockJS endpoint it could mean handling all HTTP 029 * requests defined in the SockJS protocol. 030 * 031 * @author Rossen Stoyanchev 032 * @since 5.0 033 * @see org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService 034 */ 035public interface WebSocketService { 036 037 /** 038 * Handle the request with the given {@link WebSocketHandler}. 039 * @param exchange the current exchange 040 * @param webSocketHandler handler for WebSocket session 041 * @return a {@code Mono<Void>} that completes when application handling of 042 * the WebSocket session completes. 043 */ 044 Mono<Void> handleRequest(ServerWebExchange exchange, WebSocketHandler webSocketHandler); 045 046}