io.rsocket.transport.netty.server.WebsocketServerTransport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rsocket-transport-netty Show documentation
Show all versions of rsocket-transport-netty Show documentation
Reactor Netty RSocket transport implementations (TCP, Websocket)
/*
* Copyright 2015-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.rsocket.transport.netty.server;
import static io.rsocket.frame.FrameLengthFlyweight.FRAME_LENGTH_MASK;
import io.netty.buffer.ByteBufAllocator;
import io.rsocket.DuplexConnection;
import io.rsocket.fragmentation.FragmentationDuplexConnection;
import io.rsocket.transport.ClientTransport;
import io.rsocket.transport.ServerTransport;
import io.rsocket.transport.TransportHeaderAware;
import io.rsocket.transport.netty.WebsocketDuplexConnection;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;
import reactor.netty.Connection;
import reactor.netty.http.server.HttpServer;
/**
* An implementation of {@link ServerTransport} that connects to a {@link ClientTransport} via a
* Websocket.
*/
public final class WebsocketServerTransport extends BaseWebsocketServerTransport
implements TransportHeaderAware {
private static final Logger logger = LoggerFactory.getLogger(WebsocketServerTransport.class);
private final HttpServer server;
private Supplier