Play Framework 2.2 を使用しています
WebSocket 接続を実装するために、Concurrent.unicast
自分のニーズに合った を使用します。
val enumerator = Concurrent.unicast[JsValue] {
channel => userIdWithChannelMap += u.id -> channel
}
ただし、 のソース コードはConcurrent.unicast
、いくつかの引数の必要性を示しています。
def unicast[E](
onStart: Channel[E] => Unit,
onComplete: => Unit = (),
onError: (String, Input[E]) => Unit = (_: String, _: Input[E]) => ())(implicit ec: ExecutionContext)
anがonComplete
のときに が実行されることを理解しています。ただし、コールバックとのメソッドの
違いは何ですか:Iteratee
Done
onComplete
map
Iteratee
/**
*
* Uses the provided function to transform the Iteratee's computed result when the Iteratee is done.
*
* @param f a function for transforming the computed result
* $paramEcSingle
*/
def map[B](f: A => B)(implicit ec: ExecutionContext): Iteratee[E, B] = this.flatMap(a => Done(f(a), Input.Empty))(ec)
その上、ソースコードEnumerator#onDoneEnumerating
で提示されたの必要性は何ですか。
実際、以下を扱う WebSocket の実装に出くわしました。
Concurrent.unicast{...}.onDoneEnumerating{...}
と混同していonComplete
ます。
誰でも違いを説明できますか?
そして特に、なぜそうであるように議論を提示しないのですか。onDoneEnumerating
Iteratee#map
Concurrent#broadcast
onComplete
unicast
Iteratee
世界に関する優れたドキュメントを見つけるのは難しい。