use of io.javalin.core.event.WsHandlerMetaInfo in project javalin by tipsy.
the class Javalin method addWsHandler.
/**
* Adds a specific WebSocket handler for the given path to the instance.
* Requires an access manager to be set on the instance.
*/
private Javalin addWsHandler(@NotNull WsHandlerType handlerType, @NotNull String path, @NotNull Consumer<WsConfig> wsConfig, @NotNull RouteRole... roles) {
Set<RouteRole> roleSet = new HashSet<>(Arrays.asList(roles));
javalinJettyServlet.addHandler(handlerType, path, wsConfig, roleSet);
eventManager.fireWsHandlerAddedEvent(new WsHandlerMetaInfo(handlerType, Util.prefixContextPath(javalinServlet.getConfig().contextPath, path), wsConfig, roleSet));
return this;
}
use of io.javalin.core.event.WsHandlerMetaInfo in project BlackOnion-Bot by Black0nion.
the class Paths method handle.
@Override
public Object handle(Context ctx, JSONObject body, Map<String, String> headers, @Nullable BlackSession session, DiscordUser user) throws Exception {
PathListener instance = PathListener.getInstance();
Map<HandlerType, List<String>> collected = instance.handlerMetaInfoList.stream().collect(Collectors.groupingBy(HandlerMetaInfo::getHttpMethod, mapping(HandlerMetaInfo::getPath, toList())));
return new JSONObject(collected).put("WS", new JSONArray(instance.wsHandlerMetaInfoList.stream().map(WsHandlerMetaInfo::getPath).toList()));
}
Aggregations