My favorites | Sign in
Logo
                
Show all Featured downloads:
pmrpc.js
Show all Featured wiki pages:
PmrpcApiDocs PmrpcTesting
People details
Project owners:
  izuzak, ivankovic.42

Last update: December 2 2009

Pmrpc is a HTML5 JavaScript library for RPC-style (remote procedure call) Inter-window and web workers communication. The library provides a simple API for exposing and calling procedures from browser windows, iFrames and web workers (both dedicated and shared web workers). In case of inter-window communication, the windows/iframes may also be on different domains. Pmrpc also provides several advanced features: callbacks similar to AJAX calls, ACL-based access control, asynchronous procedure support and fault-tolerance via retries.

The implementation of the library is based on the HTML5 Cross-document messaging 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.

Below is an example of using pmrpc. See the API docs for a full description of the API, feature list and usage examples.

Inter-window communication example (window->iFrame communication): First, a procedure is registered for remote calls in the iFrame that contains the procedure:

// [iFrame object A] - server

// load pmrpc library
<script type="text/javascript" src="pmrpc.js" />

// expose a procedure
pmrpc.register( {
  publicProcedureName : "HelloPMRPC",
  procedure : function(printParam) { alert(printParam); } } );

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

// [window object B] - client 

// load pmrpc library
<script type="text/javascript" src="pmrpc.js" />

// call the exposed procedure
pmrpc.call( {
  destination : window.frames["iFrameA"],
  publicProcedureName : "HelloPMRPC",
  params : ["Hello World!"] } ); 

Development roadmap: remote procedure discovery and publish-subscribe communication

Browser support: Firefox 3, Google Chrome, Internet Explorer 8. Visit the pmrpc testing page to see if your browser can use pmrpc.

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

Feedback: Please join the the official pmrpc discussion group, contact us on Twitter or use the issues list for feedback.









Hosted by Google Code