spark.Spark.webSocket()方法的使用及代码示例

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

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

Spark.webSocket介绍

[英]Maps the given path to the given WebSocket handler.

This is currently only available in the embedded server mode.
[中]将给定路径映射到给定的WebSocket处理程序。
这目前仅在嵌入式服务器模式下可用。

代码示例

代码示例来源:origin: mattjlewis/diozero

public static void main(String[] args) {
  port(8080);
  webSocket("/diozero", JsonWebSocket.class);
  init(); // Needed if you don't define any HTTP routes after your WebSocket routes
}

代码示例来源:origin: tipsy/spark-websocket

public static void main(String[] args) {
  staticFiles.location("/public"); //index.html is served at localhost:4567 (default port)
  staticFiles.expireTime(600);
  webSocket("/chat", ChatWebSocketHandler.class);
  init();
}

代码示例来源:origin: mgtechsoftware/smockin

void buildWebSocketEndpoints(final List<RestfulMock> mocks, final boolean logMockCalls) {
  //
  // Define all web socket routes first as the Spark framework requires this
  mocks.stream().forEach(m -> {
    if (RestMockTypeEnum.PROXY_WS.equals(m.getMockType())) {
      // Create an echo service instance per web socket route, as we need to hold the path as state within this.
      final String path = buildUserPath(m);
      Spark.webSocket(path, new SparkWebSocketEchoService(m.getExtId(), path, m.getWebSocketTimeoutInMillis(), m.isProxyPushIdOnConnect(), webSocketService, logMockCalls));
    }
  });
}

代码示例来源:origin: lamarios/Homedash2

webSocket("/ws", MainWebSocket.class);
webSocket("/ws-full-screen", FullScreenWebSocket.class);
webSocket("/ws-kiosk", SingleModuleKioskWebSocket.class);

代码示例来源:origin: iNPUTmice/caas

webSocket("/socket/*", TestLiveWebsocket.class);
ipAddress(Configuration.getInstance().getIp());
port(Configuration.getInstance().getPort());

相关文章