Changeset 261:ba0da978be55
- Timestamp:
- 04/30/2010 09:41:03 AM (4 months ago)
- Author:
- dcaoyuan
- Branch:
- default
- Message:
-
cleanup
- Location:
- blogbird/src/main/scala/org/aiotrade/httpd
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r260
|
r261
|
|
| 94 | 94 | val handler = hostRouter(req.headers("Host")) |
| 95 | 95 | // If the handler produces a reply, pass it on. |
| 96 | | handler ! Process(req, None, _ match { |
| 97 | | case Some(reply) => produce(reply) |
| 98 | | case None => |
| 99 | | }) |
| | 96 | handler ! Process(this, req, None) |
| 100 | 97 | } |
| 101 | 98 | } |
-
|
r251
|
r261
|
|
| 8 | 8 | import TypedDataImplicits._ |
| 9 | 9 | |
| 10 | | case class Process(req: Request, reply: Option[Reply], callback: Option[Reply] => Unit) |
| | 10 | case class Process(sender: Producer[Reply], req: Request, reply: Option[Reply]) |
| 11 | 11 | |
| 12 | 12 | /** |
| … |
… |
|
| 22 | 22 | def act = loop { |
| 23 | 23 | react { |
| 24 | | case Process(req, reply, callback) => |
| | 24 | case Process(sender, req, reply) => |
| 25 | 25 | val newReply = try { |
| 26 | 26 | apply(req, reply) |
| … |
… |
|
| 30 | 30 | Some(Reply(req, 500, "Internal server error")) |
| 31 | 31 | } |
| 32 | | |
| 33 | | callback(newReply) |
| | 32 | |
| | 33 | newReply foreach sender.produce |
| 34 | 34 | } |
| 35 | 35 | } |
-
|
r257
|
r261
|
|
| 39 | 39 | * Called by the coroutine's <code>run</code> method when it has produced a new output. |
| 40 | 40 | */ |
| 41 | | protected def produce(output: O) { |
| | 41 | def produce(output: O) { |
| 42 | 42 | consumer ! output |
| 43 | 43 | } |