public String path() { return nested.path(); }
/** * Rejects the websocket. */ public ServerWebSocket reject(Env env) { socket.reject(); return this; }
public String query() { return nested.query(); }
@Override public void handle(final ServerWebSocket socket) { DetectingGateway handler = this.gateway.get(); if ( handler==null ) { LOG.info("Rejecting web socket: no protocol detecting gateway deployed"); socket.reject(); return; } else if ( pathPrefix!=null && !socket.path().startsWith(pathPrefix) ) { LOG.info("Rejecting web socket: request path does not start with:"+ pathPrefix); socket.reject(); return; } LOG.info("Processing the web socket '"+socket.remoteAddress()+"' with the protocol detecting gateway"); handler.handle(SocketWrapper.wrap(socket)); }
public WsSocket(ServerWebSocket webSocket) { this.webSocket = webSocket; webSocket.query(); Map<String, List<String>> paramMap = new QueryStringDecoder("?" + webSocket.query()).parameters(); params = new LinkedHashMap<>(paramMap.size()); for (Map.Entry<String, List<String>> entry : paramMap.entrySet()) { params.put(entry.getKey(), entry.getValue().get(0)); } webSocket.dataHandler(new Handler<Buffer>() { @Override public void handle(Buffer data) { fire(data.toString()); } }); webSocket.exceptionHandler(new Handler<Throwable>() { @Override public void handle(Throwable event) { onClose(); } }); webSocket.closeHandler(new VoidHandler() { @Override protected void handle() { onClose(); } }); }
private void handlePingFromClient(String textData, Object object) { if (object instanceof ServerWebSocket) { ServerWebSocket ws = (ServerWebSocket) object; final InetSocketAddress inetSocketAddress = ws.remoteAddress(); if (debug) logger.debug("GOT PING", textData, " sending pong to ", inetSocketAddress); ws.write(new Buffer("pong")); } }
public MultiMap headers() { return nested.headers(); }
public InetSocketAddress remoteAddress() { return nested.remoteAddress(); }
@Override protected void disconnect() { webSocket.close(); }
@Override public void handle(final ServerWebSocket socket) { DetectingGateway handler = this.gateway.get(); if ( handler==null ) { LOG.info("Rejecting web socket: no protocol detecting gateway deployed"); socket.reject(); return; } else if ( pathPrefix!=null && !socket.path().startsWith(pathPrefix) ) { LOG.info("Rejecting web socket: request path does not start with:"+ pathPrefix); socket.reject(); return; } LOG.info("Processing the web socket '"+socket.remoteAddress()+"' with the protocol detecting gateway"); handler.handle(SocketWrapper.wrap(socket)); }
/** * A map of all headers in the request to upgrade to websocket */ public Value headers(Env env) { return env.wrapJava(socket.headers()); }
public ServerWebSocket reject() { return nested.reject(); }
/** * The path the websocket is attempting to connect at */ public StringValue path(Env env) { return env.createString(socket.path()); }
/** * The query string passed on the websocket uri */ public StringValue query(Env env) { return env.createString(socket.query()); }
noMatchHandler.handle(new Match(null, ws)); } else { ws.reject();
@Override public void handle(ServerWebSocket webSocket) { if (webSocket.path().startsWith(url)) { socketFactory.openWs(webSocket); } if (old != null) { old.handle(webSocket); } } };