nihulus nihulus - 5 months ago 26
Javascript Question

direct client-to-client message

I have been working with node.js for a while, now when I'm looking deeper into it, for a chat aplication instead of sending message as client - server - client, there must be some possible ways for direct client to client message sending?

Answer Source

Browsers tend to communicate with servers via HTTP. Some implement other protocols, like websockets & SPDY, but again, these are mostly client-server protocols.

Some plug-ins (like Flash & Java) can open ports and communicate client-client. (AFAIK, haven't actually used them.)

Chrome is the only browser I'm aware of that can (soon) open TCP and UDP sockets from Javascript and do direct client-client communication. At the moment normal web apps can't do this, your app needs to be run as a "Chrome Packaged App", with a special manifest file.

Here are the docs, a blog post describing the feature and a browserify module that can behave like the net node.js module in the browser.

EDIT: This should probably not be tagged as [node.js] since you're trying to run in browsers (not in your node vm), this is a Javascript / Browser question.