Skip to content

Commit

Permalink
api vertical header and uri access
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Nov 16, 2023
1 parent 7a89f01 commit d16a1e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/org/myrobotlab/vertx/ApiVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.net.SelfSignedCertificate;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.handler.CorsHandler;
Expand Down Expand Up @@ -91,6 +92,10 @@ public void start() throws Exception {
// FIXME - how to do this -> server.webSocketHandler(this::handleWebSocket);
server.webSocketHandler(new WebSocketHandler(service));
server.requestHandler(router);




// start servers
server.listen();
}
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/myrobotlab/vertx/WebSocketHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.slf4j.Logger;

import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.ServerWebSocket;

/**
Expand All @@ -26,6 +28,8 @@ public class WebSocketHandler implements Handler<ServerWebSocket> {

public final static Logger log = LoggerFactory.getLogger(WebSocketHandler.class);



/**
* reference to the MRL Vertx service / websocket and http server
*/
Expand Down Expand Up @@ -100,12 +104,18 @@ public WebSocketHandler(org.myrobotlab.service.Vertx service) {

@Override
public void handle(ServerWebSocket socket) {
// FIXME - get "id" from js client - need something unique from the js
// client
MultiMap headers = socket.headers();
String uri = socket.uri();

// FIXME - get "id" from js client - need something unique from the js
// client
// String id = r.getRequest().getParameter("id");
String id = String.format("vertx-%s", service.getName());
// String uuid = UUID.randomUUID().toString();
String uuid = socket.binaryHandlerID();
String uuid = socket.binaryHandlerID();

Connection connection = new Connection(uuid, id, service.getName());
connection.put("c-type", service.getSimpleName());
connection.put("gateway", service.getName());
Expand Down

0 comments on commit d16a1e2

Please sign in to comment.