org.jooby.Router.ws()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(216)

本文整理了Java中org.jooby.Router.ws方法的一些代码示例,展示了Router.ws的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Router.ws方法的具体详情如下:
包路径:org.jooby.Router
类名称:Router
方法名:ws

Router.ws介绍

[英]Append a new WebSocket handler under the given path.

ws(MyHandler.class);

[中]在给定路径下追加一个新的WebSocket处理程序

ws(MyHandler.class);

代码示例

代码示例来源:origin: jooby-project/jooby

/**
 * Append a new WebSocket handler under the given path.
 *
 * <pre>
 *   ws(MyHandler.class);
 * </pre>
 *
 * @param handler A message callback.
 * @param <T> Message type.
 * @return A new WebSocket definition.
 */
@Nonnull
default <T> WebSocket.Definition ws(final Class<? extends WebSocket.OnMessage<T>> handler) {
 return ws("", handler);
}

代码示例来源:origin: jooby-project/jooby

/**
 * Append a new WebSocket handler under the given path.
 *
 * <pre>
 *   ws("/ws", (socket) {@literal ->} {
 *     // connected
 *     socket.onMessage(message {@literal ->} {
 *       System.out.println(message);
 *     });
 *     socket.send("Connected"):
 *   });
 * </pre>
 *
 * @param path A path pattern.
 * @param handler A connect callback.
 * @return A new WebSocket definition.
 */
@Nonnull
default WebSocket.Definition ws(final String path, final WebSocket.OnOpen1 handler) {
 return ws(path, (WebSocket.OnOpen) handler);
}

代码示例来源:origin: jooby-project/jooby

router.ws("/livereload", ws -> {

代码示例来源:origin: jooby-project/jooby

"</html>").type(MediaType.html));
routes.ws(path, new WebShellHandler()).consumes(MediaType.json).produces(MediaType.json);

代码示例来源:origin: org.jooby/jooby

/**
 * Append a new WebSocket handler under the given path.
 *
 * <pre>
 *   ws(MyHandler.class);
 * </pre>
 *
 * @param handler A message callback.
 * @param <T> Message type.
 * @return A new WebSocket definition.
 */
@Nonnull
default <T> WebSocket.Definition ws(final Class<? extends WebSocket.OnMessage<T>> handler) {
 return ws("", handler);
}

代码示例来源:origin: org.jooby/jooby

/**
 * Append a new WebSocket handler under the given path.
 *
 * <pre>
 *   ws("/ws", (socket) {@literal ->} {
 *     // connected
 *     socket.onMessage(message {@literal ->} {
 *       System.out.println(message);
 *     });
 *     socket.send("Connected"):
 *   });
 * </pre>
 *
 * @param path A path pattern.
 * @param handler A connect callback.
 * @return A new WebSocket definition.
 */
@Nonnull
default WebSocket.Definition ws(final String path, final WebSocket.OnOpen1 handler) {
 return ws(path, (WebSocket.OnOpen) handler);
}

相关文章