I was excited by the prospect of WebRTC when I heard about it initially. It sounded like websockets but without a server. Unfortunately, all of the tutorials I have been a
I believe Matt already know, but for google guests: Yes, you can, useing DataChannels.
On your side:
channel = somePeerConnection.createDataChannel("a Label");
channel.onopen = function() { channel.send("any thing") };
On the other side:
somePeerConnection.ondatachannel = function (evt) {
evt.channel.onmessage = function (evt) {
alert( evt.data );
};
};
See this examples:
http://peerjs.com/ is evolving and gives you a websocket like syntax for p2p Data transfer between browser instances
As Justin indicated, the protocol and API are still being nailed down; at the latest IETF I submitted a draft for the minor protocol underneath the JS API. The final form will likely be very close to the current proposal in the editor's draft, but you'll likely need to wait on "onopened" from the receiving side as well.
The API is modeled on the WebSocket api to ease moving code from a WebSocket implementation to DataChannels, though not all items in WebSocket carry over (such as url), and obviously DataChannel adds a number of abilities not in WebSockets having to do with unreliable or partly-reliable data.
DataChannel has now been implemented in Firefox (18+) and Chrome (25+), though it's still early days.
For more information see the HTML5 Rocks article Getting Started with WebRTC.
This functionality is not yet implemented in any shipping WebRTC implementation. As other posters have indicated, there now is a DataChannel API in the latest WebRTC editors' draft, but the protocol for this is still being worked on. Expect to see this API live in Chrome and Firefox later this year.
This is a stab in the dark, but the latest Web API editors draft has a DataChannel
interface as part of the Peer-to-Peer Data API.
However, the current Working Draft does not have this API, so possibly it is very new and as-yet unimplemented.