Created
August 10, 2009 21:18
-
-
Save ikai/165423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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