private void handleMessages(String msgs) { if (!session.isClosed()) { if (msgs.equals("") || msgs.equals("[]")) { //Ignore empty frames } else if ((msgs.startsWith("[\"") && msgs.endsWith("\"]")) || (msgs.startsWith("\"") && msgs.endsWith("\""))) { session.handleMessages(msgs); } else { //Invalid JSON - we close the connection close(); } } }
String sessionID = rc.request().getParam("param0"); final SockJSSession session = sessions.get(sessionID); if (session != null && !session.isClosed()) { handleSend(rc, session); } else {
XhrTransport(Vertx vertx, Router router, LocalMap<String, SockJSSession> sessions, SockJSHandlerOptions options, Handler<SockJSSocket> sockHandler) { super(vertx, sessions, options); String xhrBase = COMMON_PATH_ELEMENT_RE; String xhrRE = xhrBase + "xhr"; String xhrStreamRE = xhrBase + "xhr_streaming"; Handler<RoutingContext> xhrOptionsHandler = createCORSOptionsHandler(options, "OPTIONS, POST"); router.optionsWithRegex(xhrRE).handler(xhrOptionsHandler); router.optionsWithRegex(xhrStreamRE).handler(xhrOptionsHandler); registerHandler(router, sockHandler, xhrRE, false, options); registerHandler(router, sockHandler, xhrStreamRE, true, options); String xhrSendRE = COMMON_PATH_ELEMENT_RE + "xhr_send"; router.optionsWithRegex(xhrSendRE).handler(xhrOptionsHandler); router.postWithRegex(xhrSendRE).handler(rc -> { if (log.isTraceEnabled()) log.trace("XHR send, post, " + rc.request().uri()); String sessionID = rc.request().getParam("param0"); final SockJSSession session = sessions.get(sessionID); if (session != null && !session.isClosed()) { handleSend(rc, session); } else { rc.response().setStatusCode(404); setJSESSIONID(options, rc); rc.response().end(); } }); }
private void handleMessages(String msgs) { if (!session.isClosed()) { if (msgs.equals("") || msgs.equals("[]")) { //Ignore empty frames } else if ((msgs.startsWith("[\"") && msgs.endsWith("\"]")) || (msgs.startsWith("\"") && msgs.endsWith("\""))) { session.handleMessages(msgs); } else { //Invalid JSON - we close the connection close(); } } }
String sessionID = rc.request().getParam("param0"); final SockJSSession session = sessions.get(sessionID); if (session != null && !session.isClosed()) { handleSend(rc, session); } else {
XhrTransport(Vertx vertx, Router router, LocalMap<String, SockJSSession> sessions, SockJSHandlerOptions options, Handler<SockJSSocket> sockHandler) { super(vertx, sessions, options); String xhrBase = COMMON_PATH_ELEMENT_RE; String xhrRE = xhrBase + "xhr"; String xhrStreamRE = xhrBase + "xhr_streaming"; Handler<RoutingContext> xhrOptionsHandler = createCORSOptionsHandler(options, "OPTIONS, POST"); router.optionsWithRegex(xhrRE).handler(xhrOptionsHandler); router.optionsWithRegex(xhrStreamRE).handler(xhrOptionsHandler); registerHandler(router, sockHandler, xhrRE, false, options); registerHandler(router, sockHandler, xhrStreamRE, true, options); String xhrSendRE = COMMON_PATH_ELEMENT_RE + "xhr_send"; router.optionsWithRegex(xhrSendRE).handler(xhrOptionsHandler); router.postWithRegex(xhrSendRE).handler(rc -> { if (log.isTraceEnabled()) log.trace("XHR send, post, " + rc.request().uri()); String sessionID = rc.request().getParam("param0"); final SockJSSession session = sessions.get(sessionID); if (session != null && !session.isClosed()) { handleSend(rc, session); } else { rc.response().setStatusCode(404); setJSESSIONID(options, rc); rc.response().end(); } }); }