/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.vertx.reactivex.ext.web.handler.sockjs;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
/**
*
* A handler that allows you to handle SockJS connections from clients.
* <p>
* We currently support version 0.3.3 of the SockJS protocol, which can be found in
* <a href="https://github.com/sockjs/sockjs-protocol/tree/v0.3.3">this tag:</a>
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.ext.web.handler.sockjs.SockJSHandler original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.ext.web.handler.sockjs.SockJSHandler.class)
public class SockJSHandler implements Handler<io.vertx.reactivex.ext.web.RoutingContext> {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SockJSHandler that = (SockJSHandler) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg<SockJSHandler> __TYPE_ARG = new TypeArg<>( obj -> new SockJSHandler((io.vertx.ext.web.handler.sockjs.SockJSHandler) obj),
SockJSHandler::getDelegate
);
private final io.vertx.ext.web.handler.sockjs.SockJSHandler delegate;
public SockJSHandler(io.vertx.ext.web.handler.sockjs.SockJSHandler delegate) {
this.delegate = delegate;
}
public SockJSHandler(Object delegate) {
this.delegate = (io.vertx.ext.web.handler.sockjs.SockJSHandler)delegate;
}
public io.vertx.ext.web.handler.sockjs.SockJSHandler getDelegate() {
return delegate;
}
Create a SockJS handler
Params: - vertx – the Vert.x instance
Returns: the handler
/**
* Create a SockJS handler
* @param vertx the Vert.x instance
* @return the handler
*/
public static io.vertx.reactivex.ext.web.handler.sockjs.SockJSHandler create(io.vertx.reactivex.core.Vertx vertx) {
io.vertx.reactivex.ext.web.handler.sockjs.SockJSHandler ret = io.vertx.reactivex.ext.web.handler.sockjs.SockJSHandler.newInstance((io.vertx.ext.web.handler.sockjs.SockJSHandler)io.vertx.ext.web.handler.sockjs.SockJSHandler.create(vertx.getDelegate()));
return ret;
}
Create a SockJS handler
Params: - vertx – the Vert.x instance
- options – options to configure the handler
Returns: the handler
/**
* Create a SockJS handler
* @param vertx the Vert.x instance
* @param options options to configure the handler
* @return the handler
*/
public static io.vertx.reactivex.ext.web.handler.sockjs.SockJSHandler create(io.vertx.reactivex.core.Vertx vertx, io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions options) {
io.vertx.reactivex.ext.web.handler.sockjs.SockJSHandler ret = io.vertx.reactivex.ext.web.handler.sockjs.SockJSHandler.newInstance((io.vertx.ext.web.handler.sockjs.SockJSHandler)io.vertx.ext.web.handler.sockjs.SockJSHandler.create(vertx.getDelegate(), options));
return ret;
}
Set a SockJS socket handler. This handler will be called with a SockJS socket whenever a SockJS connection
is made from a client
Params: - handler – the handler
Returns: a router to be mounted on an existing router
/**
* Set a SockJS socket handler. This handler will be called with a SockJS socket whenever a SockJS connection
* is made from a client
* @param handler the handler
* @return a router to be mounted on an existing router
*/
public io.vertx.reactivex.ext.web.Router socketHandler(Handler<io.vertx.reactivex.ext.web.handler.sockjs.SockJSSocket> handler) {
io.vertx.reactivex.ext.web.Router ret = io.vertx.reactivex.ext.web.Router.newInstance((io.vertx.ext.web.Router)delegate.socketHandler(new Handler<io.vertx.ext.web.handler.sockjs.SockJSSocket>() {
public void handle(io.vertx.ext.web.handler.sockjs.SockJSSocket event) {
handler.handle(io.vertx.reactivex.ext.web.handler.sockjs.SockJSSocket.newInstance((io.vertx.ext.web.handler.sockjs.SockJSSocket)event));
}
}));
return ret;
}
Bridge the SockJS handler to the Vert.x event bus. This basically installs a built-in SockJS socket handler
which takes SockJS traffic and bridges it to the event bus, thus allowing you to extend the server-side
Vert.x event bus to browsers
Params: - bridgeOptions – options to configure the bridge with
Returns: a router to be mounted on an existing router
/**
* Bridge the SockJS handler to the Vert.x event bus. This basically installs a built-in SockJS socket handler
* which takes SockJS traffic and bridges it to the event bus, thus allowing you to extend the server-side
* Vert.x event bus to browsers
* @param bridgeOptions options to configure the bridge with
* @return a router to be mounted on an existing router
*/
public io.vertx.reactivex.ext.web.Router bridge(io.vertx.ext.web.handler.sockjs.SockJSBridgeOptions bridgeOptions) {
io.vertx.reactivex.ext.web.Router ret = io.vertx.reactivex.ext.web.Router.newInstance((io.vertx.ext.web.Router)delegate.bridge(bridgeOptions));
return ret;
}
Like bridge
but specifying a handler that will receive bridge events. Params: - authorizationProvider – authorization provider to be used on the bridge
- bridgeOptions – options to configure the bridge with
- bridgeEventHandler – handler to receive bridge events
Returns: a router to be mounted on an existing router
/**
* Like {@link io.vertx.reactivex.ext.web.handler.sockjs.SockJSHandler#bridge} but specifying a handler
* that will receive bridge events.
* @param authorizationProvider authorization provider to be used on the bridge
* @param bridgeOptions options to configure the bridge with
* @param bridgeEventHandler handler to receive bridge events
* @return a router to be mounted on an existing router
*/
public io.vertx.reactivex.ext.web.Router bridge(io.vertx.reactivex.ext.auth.authorization.AuthorizationProvider authorizationProvider, io.vertx.ext.web.handler.sockjs.SockJSBridgeOptions bridgeOptions, Handler<io.vertx.reactivex.ext.web.handler.sockjs.BridgeEvent> bridgeEventHandler) {
io.vertx.reactivex.ext.web.Router ret = io.vertx.reactivex.ext.web.Router.newInstance((io.vertx.ext.web.Router)delegate.bridge(authorizationProvider.getDelegate(), bridgeOptions, new Handler<io.vertx.ext.web.handler.sockjs.BridgeEvent>() {
public void handle(io.vertx.ext.web.handler.sockjs.BridgeEvent event) {
bridgeEventHandler.handle(io.vertx.reactivex.ext.web.handler.sockjs.BridgeEvent.newInstance((io.vertx.ext.web.handler.sockjs.BridgeEvent)event));
}
}));
return ret;
}
Like bridge
but specifying a handler that will receive bridge events. Params: - bridgeOptions – options to configure the bridge with
- bridgeEventHandler – handler to receive bridge events
Returns: a router to be mounted on an existing router
/**
* Like {@link io.vertx.reactivex.ext.web.handler.sockjs.SockJSHandler#bridge} but specifying a handler
* that will receive bridge events.
* @param bridgeOptions options to configure the bridge with
* @param bridgeEventHandler handler to receive bridge events
* @return a router to be mounted on an existing router
*/
public io.vertx.reactivex.ext.web.Router bridge(io.vertx.ext.web.handler.sockjs.SockJSBridgeOptions bridgeOptions, Handler<io.vertx.reactivex.ext.web.handler.sockjs.BridgeEvent> bridgeEventHandler) {
io.vertx.reactivex.ext.web.Router ret = io.vertx.reactivex.ext.web.Router.newInstance((io.vertx.ext.web.Router)delegate.bridge(bridgeOptions, new Handler<io.vertx.ext.web.handler.sockjs.BridgeEvent>() {
public void handle(io.vertx.ext.web.handler.sockjs.BridgeEvent event) {
bridgeEventHandler.handle(io.vertx.reactivex.ext.web.handler.sockjs.BridgeEvent.newInstance((io.vertx.ext.web.handler.sockjs.BridgeEvent)event));
}
}));
return ret;
}
Params: - routingContext – the rounting context
/**
* @param routingContext the rounting context
*/
@Deprecated()
public void handle(io.vertx.reactivex.ext.web.RoutingContext routingContext) {
delegate.handle(routingContext.getDelegate());
}
public static SockJSHandler newInstance(io.vertx.ext.web.handler.sockjs.SockJSHandler arg) {
return arg != null ? new SockJSHandler(arg) : null;
}
}