<commit_before>WebSockets RPC/PubSub for JS
============================

What is that?
-------------

WebSockets <http://tools.ietf.org/html/rfc6455> is already built into
modern browsers and provides full-duplex, low-latency communication.

However, as such, it is quite low-level. Web apps often have
a need for higher level messaging patterns:

  * Publish & Subscribe
  * Remote Procedure Calls

This is where **WAMP** enters. WAMP (WebSocket Application Messaging Protocol)
runs on top of raw WebSocket and provides *PubSub* and *RPC*.

Technically, WAMP is a proper WebSocket *subprotocol* that uses JSON as
message serialization format.


Show me the code!
-----------------

This is how you connect and subscribe to receive events on a topic ..

      var sess;

      function onEvent1(topic, event) {
         alert("got event: " + event);
      }

      $(document).ready(function() {
         sess = new ab.Session("ws://localhost:9000", function() {

            sess.prefix("event", "http://example.com/event#");
            sess.subscribe("event:event1", onEvent1);
         });
      });


.. and publish and event to a topic


      sess.publish("event:event1", {a: 23, b: "foobar"});

      ...

      <button onclick="sendMyEvent();">Publish!</button>



<commit_msg>improve readme<commit_after>WebSockets RPC/PubSub for JS
============================

What is that?
-------------

WebSockets <http://tools.ietf.org/html/rfc6455> is already built into
modern browsers and provides full-duplex, low-latency communication.

However, as such, it is quite low-level. Web apps often have
a need for higher level messaging patterns:

  * Publish & Subscribe
  * Remote Procedure Calls

This is where **WAMP** enters. WAMP (WebSocket Application Messaging Protocol)
runs on top of raw WebSocket and provides *PubSub* and *RPC*.

Technically, WAMP is a proper WebSocket *subprotocol* that uses JSON as
message serialization format.


Show me the code!
-----------------

This is how you do publish & subscribe with AutobahnJS.

Include required libs

      <script src="http://code.jquery.com/jquery.min.js"></script>
      <script src="http://autobahn.ws/public/autobahn.min.js"></script>

.. connect and subscribe to receive events on a topic

      var sess;

      function onEvent1(topic, event) {
         alert("got event: " + event);
      }

      $(document).ready(function() {
         sess = new ab.Session("ws://localhost:9000", function() {

            sess.prefix("event", "http://example.com/event#");
            sess.subscribe("event:event1", onEvent1);
         });
      });


.. and publish and event to a topic


      sess.publish("event:event1", {a: 23, b: "foobar"});

      ...

      <button onclick="sendMyEvent();">Publish!</button>
{'fraction_non_alphanumeric': 0.15495495495495495, 'fraction_numerical': 0.01009009009009009, 'mean_word_length': 2.915373765867419, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7331040', 'n_tokens_mistral': 845, 'n_tokens_neox': 788, 'n_words': 265}