-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
65 lines (51 loc) · 2.15 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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();