Simple IPC between local HTML5 App Instances Using Hash Routing

Consider the following little fragment of HTML:

<a href="./#/monitor2" target="monitor2" title="Open monitor #2 instance of #{appName}">Monitor #2</a>
<a href="./#/monitor3" target="monitor3" title="Open monitor #3 instance of #{appName}">Monitor #3</a>
<a href="./#/monitor3/run" target="monitor3" "test">Test directed at monitor 3</a>

Here I’m using a named target in my A tags to make an IPC request on another instance of my single page HTML5 application that’s running in another browser tab, or a completely different instance of the browser on localhost.

Although just implied by the trivial code above, whatever request you want can be serialized into a hash route and sent in this fashion. But that’s just one way!

Ah yes, but the requester can embed its own window target in the request and the receiver can respond in kind.

Local IPC via hash routes. That’s cool provided that your requests are small enough. (remember practical ~2K character limit on URI’s in the wild).

Of course another alternative to this is to use some sort of mailbox in local storage. But necessarily this is a little bit more complicated, likely involves a lot more code, and isn’t as widely supported yet.

My thinking is some combination of the two methods is really useful.

Advertisements

About Chris Russell

http://www.chrisrussell.net
This entry was posted in Internet, Open Source, Software and tagged , , , . Bookmark the permalink.

One Response to Simple IPC between local HTML5 App Instances Using Hash Routing

Comment on this article

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s