Skip to content

Instantly share code, notes, and snippets.

@ikai
Created August 10, 2009 21:18
Show Gist options
  • Save ikai/165423 to your computer and use it in GitHub Desktop.
Save ikai/165423 to your computer and use it in GitHub Desktop.
import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.Context
import org.mortbay.jetty.servlet.ServletHolder;
object Main {
def main(args: Array[String]) {
var server = new Server(8080)
println("Starting world server")
var root = new Context(server,"/",Context.SESSIONS);
var servlet = new ScalaServlet
root.addServlet(new ServletHolder(servlet), "/*");
server.start();
}
}
import javax.servlet.http._;
import com.zombies.world._
import com.zombies.commands._
class ScalaServlet extends HttpServlet {
val world = Multiverse.getWorldInstance
override def init() {
}
override def doGet(request : HttpServletRequest , response : HttpServletResponse) = {
service(request, response)
}
override def service(req: HttpServletRequest,resp: HttpServletResponse) {
val pw = resp.getWriter();
var output = dispatch(req.getRequestURI, req.getMethod);
pw.println(output);
pw.flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment