Chat class Chat extends Comet Actor with Comet

  • Slides: 11
Download presentation

Chat コンポーネントの定義 class Chat extends Comet. Actor with Comet. Listener { private var msgs:

Chat コンポーネントの定義 class Chat extends Comet. Actor with Comet. Listener { private var msgs: List[String] = Nil def register. With = Chat. Server override def low. Priority = { case m: List[String] => msgs = m; re. Render(false) } import scala. xml. Node. Seq def render = bind("chat", // バインディングのための名前空間 "line" -> lines _, // 関数 lines をバインド "input" -> SHtml. text("", s => Chat. Server ! s)) private def lines(xml: Node. Seq): Node. Seq = msgs. reverse. flat. Map(m => bind("chat", xml, "msg" -> m)) } 解説は次ページ

Index. htmlの中身 <lift: surround with="default" at="content"> <lift: comet type="Chat"> <ul> <chat: line> <li><chat: msg/></li>

Index. htmlの中身 <lift: surround with="default" at="content"> <lift: comet type="Chat"> <ul> <chat: line> <li><chat: msg/></li> </chat: line> </ul> <lift: form> <chat: input/> <input type="submit" value="chat"/> </lift: form> </lift: comet> </lift: surround>