Create a gist now

Instantly share code, notes, and snippets.

Embed
Implementação de servidor jetty embarcado com Java WebSocket API e Scalatra. :-)
def main(args: Array[String]) {
val port = restApiConfig.getInt("port")
println(restApiConfig.getString("resourceBase"))
val server = new Server(port)
val context = new WebAppContext()
context setContextPath "/"
context.setResourceBase(restApiConfig.getString("resourceBase"))
context.setInitParameter(ScalatraListener.LifeCycleKey, "com.opportunity.simple.restapi.ScalatraBootstrap")
context.addEventListener(new ScalatraListener)
context.addServlet(classOf[DefaultServlet],"/")
server.setHandler(context)
val wscontainer:ServerContainer = WebSocketServerContainerInitializer.configureContext(context)
wscontainer.setDefaultMaxSessionIdleTimeout(1000 * 60 * 30)
wscontainer.addEndpoint(classOf[MyEchoSocket])
server.start
server.join
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment