-
Notifications
You must be signed in to change notification settings - Fork 0
Bidirectional message channel between a servlet container and a browser
License
ritschwumm/rumms
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Bidirectional message channel between a servlet container and a browser Facts - uses only a single HTTP connection - built on top of jetty continuations - messages are JSON encoded To build this code, get and install SBT from https://github.com/sbt/sbt Get and install these library/libraries before building: https://github.com/ritschwumm/scutil https://github.com/ritschwumm/scjson https://github.com/ritschwumm/scwebapp Use these commands to build: git clone [email protected]:ritschwumm/rumms.git cd rumms sbt publish-local Usage Add this code to your web.xml <listener> <listener-class>demo.DemoContextListener</listener-class> </listener> Note: If this servlet is reached through a filter, that filter must have <async-supported>true</async-supported> set, too. Implement the DemoContextListener package demo import javax.servlet._ import rumms._ final class DemoContextListener(sc:ServletContext) extends ServletContextListener { @volatile var rumms:Option[Rumms] = None def contextInitialized(ev:ServletContextEvent) { val config = RummsConfiguration("/rumms", "0") val rumms = Rumms create (ev.getServletContext, config) rumms start new RummsCallbacks { // ... } } def contextDestroyed(ev:ServletContextEvent) { rumms foreach { _.dispose() } } } In the webapp, include the client code like this <script type="text/javascript" src="rumms/code?_="></script> and connect to the server like this var conversation = new rumms.Conversation({ connected: function(conversationId) { ... }, disconnected: function(conversationId) { ... }, upgraded: function(version) { ... }, message: function(object) { ... }, heartbeat: function() { ... }, error: function(object) { ... }//, }); conversation.connect();
About
Bidirectional message channel between a servlet container and a browser
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published