scala – Basic Play 2.0找不到WebSocket请求标头
发布时间:2020-12-16 18:58:22 所属栏目:安全 来源:网络整理
导读:我正在尝试使用Play 2.0 websockets做一个非常简单的概念验证. 这是我现在在做什么: 在我的控制器中定义WebSocket: def wsrequest = WebSocket.using[String] { request = // Send a single 'Hello!' message val out = Enumerator("Hello!") // Just cons
我正在尝试使用Play 2.0 websockets做一个非常简单的概念验证.
这是我现在在做什么: >在我的控制器中定义WebSocket: def wsrequest = WebSocket.using[String] { request => // Send a single 'Hello!' message val out = Enumerator("Hello!") // Just consume and ignore the input val in = Iteratee.consume[String]() // tie the in and out values to each other (in,out) } >在我的路由文件中添加路由 GET /wsrequest controllers.Application.wsrequest >在我的index.scala.html中的javascript中使用以下内容: var sock = new WS("@routes.Application.wsrequest().webSocketURL()") 但是,当我尝试编译这个我收到一个错误: [info] Compiling 5 Scala sources and 1 Java source to targetscala-2.9.1classes... [error] targetscala-2.9.1src_managedmainviewshtmlindex.template.scala:32: Cannot find any HTTP Request Header here [error] Error occurred in an application involving default arguments. [error] var sock = new WS(""""),_display_(Seq[Any](/*11.33*/routes/*11.39*/.Application.wsrequest().webSocketURL())),format.raw/*11.78*/("""") [error] ^ [error] one error found 我错过了一步吗?还是我以前做过的错误? 解决方法
您的模板需要一个隐式请求标头,如下所示:
@(message: String)(implicit request: RequestHeader) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |