Allow two clients interact without server

chat, javascript

Solution

The WebRTC APIs will allow JavaScript to initiate a direct browser-to-browser connection, but a server is still required to serve the page and coordinate session initiation.

The APIs are still rapidly evolving and only available in bleeding-edge browsers, so it's not yet ready for real production use.

However—to be honest—for what you're trying to do, the easiest option is Node and socket.io:

var http=require('http'), express=require('express'), sio = require('socket.io')
    , app=express(), srv = http.createServer(app);

app.use(express.static(__dirname+'/static'));

sio.listen(srv);
srv.listen(80);

...and now you have a working websockets server in 5 lines. Put all your client-side stuff in the static folder and you're good to go.

Problem

Is it possible to allow two clients interact directly without a server? I am referring to websites, for example is it possible to create a chat between two clients that are on the same website using only `javascript` on the client-side. If not, what's the minimum server-side to make a chat work between active clients on a website? (eg: one `PHP` file and no database) ? My idea: Storing the conversation would be easily done using `localStorage` on each client, the problem is how to send some data from `client1` to `client2` without storing anything (or at most that message) in the database. Also, note that "past" conversations should not visible, so no storage needed for that. Note that I don't want any nodeJS or websocket solutions, I want something as simple as possible. So, what's the minimum `code` and `files` to make a chat between online users?

Original source

Related problems