diy / intercom.js

UNMAINTAINED: A client-side cross-window message broadcast library built on top of the HTML5 localStorage API.
566 stars 91 forks source link

Does Intercom.js require Node.js or Socket.io #12

Closed iamdriz closed 9 years ago

iamdriz commented 9 years ago

From the introduction it says that intercom.js includes a binding for socket.io, but doesn't elaborate if it's a requirement for it to work... or if node.js is required.

Also what is the main difference between socket.io and intercom.js?

Thanks

brianreavis commented 9 years ago

@iamdriz Intercom.js is a clientside library – it does not require Node. Socket.io is not required. There's just some binding code that makes connecting intercom to socket.io a lot easier.

iamdriz commented 9 years ago

How does it differ from postMessage then?

Sent from my iPhone

On 16 Oct 2014, at 21:26, Brian Reavis notifications@github.com wrote:

@iamdriz Intercom.js is a clientside library – it does not require Node. Socket.io is not required. There's just some binding code that makes connecting intercom to socket.io a lot easier.

— Reply to this email directly or view it on GitHub.

brianreavis commented 9 years ago

Intercom is all about communicating between tabs (multiple processes) in your domain. The postMessage API is for communicating w/third-party frames within your current process.

iamdriz commented 9 years ago

Third party frames? Meaning you can't talk to two windows/tabs on the same domain with postMessage like this question: http://stackoverflow.com/questions/26409584/postmessage-not-sending-data

The docs at Mozilla seem to give this impression: https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage but I guess I misunderstood what cross-origin means!

So what's the main difference between sockets.io and intercom.js?

brianreavis commented 9 years ago

Re: postMessage – You can talk to same-domain frames in the current window, but not across tabs. Re: Intercom vs Socket.io – Socket.io is server<->client communication over sockets. Intercom is client<->client communication across tabs via a localStorage trick.

iamdriz commented 9 years ago

Does Intercom.js support newly opened windows? Like this:

Index.html: http://pastebin.com/u9vatx5H

And the projector window that should be receiving the messages: http://pastebin.com/Lbj2M6ux

As I don't get any errors but don't see the message. Thanks.

brianreavis commented 9 years ago

You're initializing intercom in the popup window after the message has already been sent. If I change the timeout in projector.html from 2000 to 0 it works just fine for me. Also: you'll need to run this all via a server, not by directly opening the files in your browser. Something like http-server is great for testing.

iamdriz commented 9 years ago

Okies thanks for the help, that clears things up.

carcinocron commented 9 years ago

I use Intercom.js without the sockets at all, it works pretty good. As a plus, I'm planning on adding sockets to my project soon.