Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
HTML5 inter-window and Web workers RPC and publish-subscribe communication library
JavaScript
branch: master

README.markdown

Introduction

Pmrpc is an HTML5 JavaScript library for message passing, remote procedure call and publish-subscribe cross-contex communication in the browser. The library provides a simple API for exposing and calling procedures between browser windows, iframes and web workers, even between different origins. Pmrpc also provides several advanced features: callbacks similar to AJAX calls, ACL-based access control, asynchronous procedure support and fault-tolerance via retries. In case this wasn't clear, pmrpc is not a library for browser-server communication, it is a library for communication within the browser.

The implementation of the library is based on the HTML5 Cross-document messaging postMessage API, Web Workers API, the JSON-RPC protocol and the JSON data format. Pmrpc uses the postMessage API as an underlying communication mechanism and extends it to a RPC model using the JSON-RPC, a transport-independent protocol that uses JSON for formatting messages.

Documentation

The complete list of features and the full API reference is here.

We have also written several blog posts about Pmrpc and cross-context communication:

and several papers:

Cross-context communication systems and libraries

We also maintain a systematized list of other cross-context communication libraries and systems - check it out here.

Example

Below is a hello world example of using pmrpc. For more examples, see the examples folder. See the API docs for a full description of the API, feature list and usage examples.

Inter-window communication example (parent window invokes procedure in nested iframe):

First, a procedure is registered for remote calls in the iframe that contains the procedure:

<html>
  <head>
    <script type="text/javascript" src="http://izuzak.github.com/pmrpc/pmrpc.js"></script>
  </head>
  <body>
    <script type="text/javascript">
      // expose a procedure
      pmrpc.register( {
        publicProcedureName : "HelloPMRPC",
        procedure : function(printParam) { alert(printParam); } }
      );
    </script>
  </body>
</html>

Second, the procedure is called from the parent window by specifying the iframe object which contains the remote procedure, name of the procedure and parameters:

<html>
  <head>
    <script type="text/javascript" src="http://izuzak.github.com/pmrpc/pmrpc.js"></script>
  </head>
  <body>
    <iframe id="ifr" name="ifr" src="iframe.html" width="0" height="0" frameborder=0></iframe>
    <script type="text/javascript">
      // call the exposed procedure
      pmrpc.call( {
        destination : window.frames["ifr"],
        publicProcedureName : "HelloPMRPC",
        params : ["Hello World!"] } );
    </script>
  </body>
</html>

Browser support

Pmrpc should work on Firefox 3+, Google Chrome, Opera 10.60+, Internet Explorer 8+.

Visit the pmrpc testing page to see if your browser can use pmrpc. In general, pmrpc is designed to work with the latest version of all popular browsers, we have no interest or intention to support old browser version (e.g. Firefox 2, IE6).

License

Pmrpc was developed by Ivan Zuzak and Marko Ivankovic and is available under the Apache v2.0 license.

Projects using pmrpc

  • Taverna - Workflow construction and execution environment used in many domains, but particularly life sciences.

  • edudip - Platform for live Online Courses.

  • Responsive Open Learning Environments - ROLE - European 7th Framework Programme (thanks to Bodo von der Heiden). "ROLE will create an individual world for learning with personalization intelligence on the user's side. ROLE will reach this objective by enabling the user to easily construct and maintain her own personal learning environment (PLE) consisting of a mix of preferred learning tools, learning services, learning resources and other related technologies."

  • OpenLaszlo - An open source platform for the development and delivery of rich Internet applications.

Credits

gaugestracking alpha

Something went wrong with that request. Please try again.