joewalnes/webbit — Issue #41: Stopping server does not stop server cleanly
Author: kerash
Created: 2011-10-13 16:59:29+00:00
State: open

I have still an issue with server not stopping cleanly after there has been at least one client.

Tested with Scala version 2.9.0.1 (OpenJDK 64-Bit Server VM, Java 1.6.0_23)
webbit version 78ec14159790008cf09f49ac98374797dda3c01d

Tested with following test program.

$ scalac -cp build/webbit-merged.jar test.scala
$ scala -cp build/webbit-merged.jar Test
\# connect with browser and send text "exit"

test.scala

```scala
import org.webbitserver._
import org.webbitserver.handler._
class WebSocketClient(server:WebServer) extends WebSocketHandler {
override def onPong(conn:WebSocketConnection, msg:String) = {
print("pong: "+ msg)
}
override def onMessage(conn:WebSocketConnection, msg:String) = {
println("message: "+ msg)
msg match {
case "exit" => {
server.stop;
println("stopping...");
server.join
println("done")
}
case _ => conn.send(msg.reverse)
}
}
override def onMessage(conn:WebSocketConnection, msg:Array[Byte]) = {}
override def onClose(conn:WebSocketConnection) = {
println("close: "+ conn)
}
override def onOpen(conn:WebSocketConnection) = {
println("open: "+ conn)
conn.send("hello world")
}
}

object Test {
def main(args:Array[String]) = {
val wsServer = WebServers.createWebServer(8080)
val wsClient = new WebSocketClient(wsServer)
wsServer.add("/ws", wsClient)
.add(new StaticFileHandler("."))
wsServer.start

}
}
```

index.html

```html

Send

```