Java Code Examples for io.vertx.core.http.ServerWebSocket#path()

The following examples show how to use io.vertx.core.http.ServerWebSocket#path() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WSLocalHandler.java    From vert.x-microservice with Apache License 2.0 5 votes vote down vote up
private void findServiceEntryAndRegisterWS(final ServerWebSocket serverSocket, final ServiceInfoHolder resultHolder) {
    if (resultHolder != null) {
        final String path = serverSocket.path();
        log("find entry : " + path);
        final Optional<Operation> operationResult = findServiceInfoEntry(resultHolder, path);
        operationResult.ifPresent(op ->
                        createEndpointDefinitionAndRegister(serverSocket)
        );
    }
}
 
Example 2
Source File: WSClusterHandler.java    From vert.x-microservice with Apache License 2.0 5 votes vote down vote up
private void findServiceEntryAndRegisterWS(final ServerWebSocket serverSocket, final ServiceInfoHolder resultHolder, final SharedData sharedData) {
    if (resultHolder != null) {
        final String path = serverSocket.path();
        log("find entry : " + path);
        final Optional<Operation> operationResult = findServiceInfoEntry(resultHolder, path);
        operationResult.ifPresent(op ->
                        createEndpointDefinitionAndRegister(serverSocket, sharedData)
        );
    }
}
 
Example 3
Source File: WSClusterHandler.java    From vert.x-microservice with Apache License 2.0 5 votes vote down vote up
private void updateWSEndpointHolder(ServerWebSocket serverSocket, AsyncMap<String, WSEndpointHolder> registryMap, AsyncResult<WSEndpointHolder> wsEndpointHolder) {
    log("add entry: " + Thread.currentThread());
    final String binaryHandlerId = serverSocket.binaryHandlerID();
    final String textHandlerId = serverSocket.textHandlerID();
    final String path = serverSocket.path();
    final EventBus eventBus = vertx.eventBus();
    final WSEndpoint endpoint = new WSEndpoint(binaryHandlerId, textHandlerId, path);
    final WSEndpointHolder result = wsEndpointHolder.result();
    if (result != null) {
        addDefinitionToRegistry(serverSocket, eventBus, path, endpoint, registryMap, result);
    } else {
        createEntryAndAddDefinition(serverSocket, eventBus, path, endpoint, registryMap);
    }
}
 
Example 4
Source File: WSRouteMatcher.java    From vert.x-microservice with Apache License 2.0 5 votes vote down vote up
public void accept(ServerWebSocket ws){
    final String path = ws.path();
    if(routes.containsKey(path)) {
           sessions.put(ws,path);
           Handler handler = routes.get(path);
           ws.handler(handler);
    }else {
        //TODO error handling
    }
}
 
Example 5
Source File: WebSocketRouter.java    From festival with Apache License 2.0 4 votes vote down vote up
public void accept(ServerWebSocket serverWebSocket) {
    String path = serverWebSocket.path();

    if (!webSocketRouteMap.containsKey(path)) {
        serverWebSocket.reject();
        return;
    }

    WebSocketRoute webSocketRoute = webSocketRouteMap.get(path);

    webSocketRoute.doOpen(serverWebSocket);

    serverWebSocket.frameHandler(frame -> webSocketRoute.doActive(serverWebSocket, frame));

    serverWebSocket.closeHandler((Void) -> webSocketRoute.doClose(serverWebSocket));
}
 
Example 6
Source File: WSLocalHandler.java    From vert.x-microservice with Apache License 2.0 3 votes vote down vote up
private void createEndpointDefinitionAndRegister(ServerWebSocket serverSocket) {
    final SharedData sharedData = this.vertx.sharedData();
    final LocalMap<String, byte[]> wsRegistry = sharedData.getLocalMap(WS_REGISTRY);
    final WSEndpointHolder holder = getWSEndpointHolderFromSharedData(wsRegistry);
    final String path = serverSocket.path();
    final WSEndpoint endpoint = new WSEndpoint(serverSocket.binaryHandlerID(), serverSocket.textHandlerID(), path);

    replaceOrAddEndpoint(wsRegistry, holder, endpoint);

    sendToWSService(serverSocket, path, endpoint);


}