Comparison

mod_muc_eventsource/README.markdown @ 2883:7c16afc70d11

mod_muc_eventsource: New module forked from mod_pubsub_eventsource, exposes room message stream over SSE
author Matthew Wild <mwild1@gmail.com>
date Mon, 19 Feb 2018 22:17:38 +0000
child 5923:694b62d8a82f
comparison
equal deleted inserted replaced
2882:6f289283feb1 2883:7c16afc70d11
1 ---
2 labels: 'Stage-Beta'
3 summary: Subscribe to MUC rooms using the HTML5 EventSource API
4 ...
5
6 Introduction
7 ------------
8
9 This module and its docs shamelessly forked from mod_pubsub_eventsource.
10
11 [Server-Sent Events](https://en.wikipedia.org/wiki/Server-sent_events)
12 is a simple HTTP/line-based protocol supported in HTML5, making it easy
13 to receive a stream of "events" in realtime using the Javascript
14 [EventSource
15 API](https://developer.mozilla.org/en-US/docs/Web/API/EventSource).
16
17 EventSource is supported in [most modern
18 browsers](http://caniuse.com/#feat=eventsource), and for the remainder
19 there are 'polyfill' compatibility layers such as
20 [EventSource.js](https://github.com/remy/polyfills/blob/master/EventSource.js)
21 and [jquery.eventsource](https://github.com/rwldrn/jquery.eventsource).
22
23 Details
24 -------
25
26 Subscribing to a node from Javascript is easy:
27
28 var source = new EventSource('http://muc.example.org:5280/eventsource/myroom');
29 source.onmessage = function (event) {
30 console.log(event.data); // Do whatever you want with the data here
31 };
32
33 ### Access control
34
35 Be warned that this module currently performs no access control. It will expose
36 the messages of ALL rooms on the host it is loaded on. This may be changed in
37 future revisions.
38
39 ### Cross-domain issues
40
41 The same cross-domain restrictions apply to EventSource that apply to
42 BOSH, and support for CORS is not clearly standardized yet. You may want
43 to proxy connections through your web server for this reason. See [BOSH:
44 Cross-domain
45 issues](https://prosody.im/doc/setting_up_bosh#proxying_requests) for
46 more information.
47
48 Configuration
49 -------------
50
51 There is no special configuration for this module. Simply load it onto a
52 MUC component like so:
53
54 Component "muc.example.org" "muc"
55 modules_enabled = { "muc_eventsource" }
56
57 As it uses HTTP to serve the event streams, you can use Prosody's
58 standard [HTTP configuration options](https://prosody.im/doc/http) to
59 control how/where the streams are served.
60
61 **Note about URLs:** It is important to get the event streams from the
62 correct hostname (that of the MUC host). An example stream URL is
63 `http://muc.example.org:5280/eventsource/myroom`. If you need to
64 access the streams using another hostname (e.g. `example.org`) you can
65 use the `http_host` option under the Component, e.g.
66 `http_host = "example.org"`. For more information see the ['Virtual
67 Hosts'](https://prosody.im/doc/http#virtual_hosts) section of our HTTP
68 documentation.
69
70 Compatibility
71 -------------
72
73 ------- --------------
74 0.10 ?
75 0.9 ?
76 0.8 Doesn't work
77 Trunk Works
78 ------- --------------