Skip to content

Commit

Permalink
[] (0) peer-to-peer ideas: make the configuration stuff async and rep…
Browse files Browse the repository at this point in the history
…eatable, and make it possible to give the server object details of some third-party server that does routing or whatnot.

git-svn-id: http://svn.whatwg.org/webapps@4858 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 22, 2010
1 parent d2b51b9 commit 58d888e
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 44 deletions.
97 changes: 82 additions & 15 deletions complete.html
Expand Up @@ -157,7 +157,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<hgroup><h1>Web Applications 1.0</h1>
<h2 class="no-num no-toc">Draft Standard &mdash; 17 March 2010</h2>
<h2 class="no-num no-toc">Draft Standard &mdash; 22 March 2010</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
Expand Down Expand Up @@ -45387,39 +45387,106 @@ <h5 id=peer-to-peer-connections><span class=secno>4.11.6.2 </span>Peer-to-peer c
<pre class=idl>[NoInterfaceObject]
interface <dfn id=abstractpeer>AbstractPeer</dfn> {
void sendText(in DOMString text);
attribute Function ontext; // receiving
attribute <a href=#function>Function</a> ontext; // receiving

void sendBitmap(in HTMLImageElement image);
attribute Function onbitmap; // receiving
attribute <a href=#function>Function</a> onbitmap; // receiving

void sendFile(in File file);
attribute Function onfile; // receiving
attribute <a href=#function>Function</a> onfile; // receiving

attribute Stream localStream; // video/audio to send
readonly attribute Stream remoteStream; // video/audio from remote peer
attribute Function onstreamchange; // when the remote peer changes whether the video is being sent or not
attribute <a href=#stream>Stream</a> localStream; // video/audio to send
readonly attribute <a href=#stream>Stream</a> remoteStream; // video/audio from remote peer
attribute <a href=#function>Function</a> onstreamchange; // when the remote peer changes whether the video is being sent or not

attribute Function onconnect; // called when the connection is established
attribute Function ondisconnect;
attribute <a href=#function>Function</a> onconnect;
attribute <a href=#function>Function</a> onerror;
attribute <a href=#function>Function</a> ondisconnect;
};

[Constructor]
[Constructor(in DOMString serverConfiguration)]
interface <dfn id=peertopeerserver>PeerToPeerServer</dfn> : <a href=#abstractpeer>AbstractPeer</a> {
DOMString <span title=dom-PeerToPeerServer-getAddress>getAddress</span>(); // returns a string that encodes all the various ways to connect to this peer

attribute Function onincoming; // incoming call detected
void <span title=dom-PeerToPeerServer-getClientConfiguration>getClientConfiguration</span>(in <a href=#peertopeerconfigurationcallback>PeerToPeerConfigurationCallback</a> callback);
<!--(doesn't make much sense to not accept it, after going to all the effort of setting it up)
attribute <span>Function</span> onincoming; // incoming call detected
void accept(); // accepts incoming call
void reject(in optional DOMString message); // explicitly rejects incoming call

-->
void close(); // disconnects and stops listening
};

[Constructor(in DOMString address)] // pass it the result of getAddress() from the other peer
[Constructor]
interface <dfn id=peertopeerclient>PeerToPeerClient</dfn> : <a href=#abstractpeer>AbstractPeer</a> {
void <span title=dom-PeerToPeerClient-addConfiguration>addConfiguration</span>(in DOMString configuration);
void close(); // disconnects
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn id=peertopeerconfigurationcallback>PeerToPeerConfigurationCallback</dfn> {
void <span title=dom-PeerToPeerConfigurationCallback-handleEvent>handleEvent</span>(in <a href=#peertopeerserver>PeerToPeerServer</a> server, in DOMString configuration);
};</pre>

<p class=XXX>...</p>

<div class=XXX>

<p>This relies on some currently hypothetical other standard to
define:</p>

<ul><li>The format of server configuration strings.
<li>The format of client configuration strings.
<li>The protocols that servers and clients use to talk to third-party servers mentioned in the server configuration strings.
<li>The protocols that servers and clients use to talk to each other.
</ul></div>

<div class=example>

<p>Server:</p>

<pre>var serverConfig = ...; // configuration string obtained from server
// contains details such as the IP address of a server that can speak some
// protocol to help the client determine its public IP address, route packets
// if necessary, etc.

var local = new PeerToPeerServer(serverConfig);
local.getClientConfiguration(function (configuration) {
if (configuration != '') {
...; // send configuration to other peer using out-of-band mechanism
} else {
// we've exhausted our options; wait for connection
}
});</pre>

<p>Client:</p>

<pre>var local = new PeerToPeerClient();
function ... (configuration) {
// called whenever we get configuration information out-of-band
local.addConfiguration(configuration);
}</pre>

<p>Both client and server:</p>

<pre>local.onconnect = function (event) {
// we are connected!
local.sendText('Hello');
local.localStream = ...; // send video
local.onstreamchange = function (event) {
// receive video
// (videoElement is some &lt;video&gt; element)
videoElement.src = local.remoteStream.URL;
};
};</pre>

</div>

<p class=warning>To prevent network sniffing from allowing a
fourth party to establish a connection to the
<code><a href=#peertopeerserver>PeerToPeerServer</a></code> using the information sent out-of-band
to the <code><a href=#peertopeerclient>PeerToPeerClient</a></code> and thus spoofing the client,
the configuration information should always be transmitted using an
encrypted connection.</p>




Expand Down
97 changes: 82 additions & 15 deletions index
Expand Up @@ -161,7 +161,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<hgroup><h1>HTML5 (including next generation additions still in development)</h1>
<h2 class="no-num no-toc">Draft Standard &mdash; 17 March 2010</h2>
<h2 class="no-num no-toc">Draft Standard &mdash; 22 March 2010</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
Expand Down Expand Up @@ -45289,39 +45289,106 @@ interface <dfn>DataGridListener</dfn> {
<pre class=idl>[NoInterfaceObject]
interface <dfn id=abstractpeer>AbstractPeer</dfn> {
void sendText(in DOMString text);
attribute Function ontext; // receiving
attribute <a href=#function>Function</a> ontext; // receiving

void sendBitmap(in HTMLImageElement image);
attribute Function onbitmap; // receiving
attribute <a href=#function>Function</a> onbitmap; // receiving

void sendFile(in File file);
attribute Function onfile; // receiving
attribute <a href=#function>Function</a> onfile; // receiving

attribute Stream localStream; // video/audio to send
readonly attribute Stream remoteStream; // video/audio from remote peer
attribute Function onstreamchange; // when the remote peer changes whether the video is being sent or not
attribute <a href=#stream>Stream</a> localStream; // video/audio to send
readonly attribute <a href=#stream>Stream</a> remoteStream; // video/audio from remote peer
attribute <a href=#function>Function</a> onstreamchange; // when the remote peer changes whether the video is being sent or not

attribute Function onconnect; // called when the connection is established
attribute Function ondisconnect;
attribute <a href=#function>Function</a> onconnect;
attribute <a href=#function>Function</a> onerror;
attribute <a href=#function>Function</a> ondisconnect;
};

[Constructor]
[Constructor(in DOMString serverConfiguration)]
interface <dfn id=peertopeerserver>PeerToPeerServer</dfn> : <a href=#abstractpeer>AbstractPeer</a> {
DOMString <span title=dom-PeerToPeerServer-getAddress>getAddress</span>(); // returns a string that encodes all the various ways to connect to this peer

attribute Function onincoming; // incoming call detected
void <span title=dom-PeerToPeerServer-getClientConfiguration>getClientConfiguration</span>(in <a href=#peertopeerconfigurationcallback>PeerToPeerConfigurationCallback</a> callback);
<!--(doesn't make much sense to not accept it, after going to all the effort of setting it up)
attribute <span>Function</span> onincoming; // incoming call detected
void accept(); // accepts incoming call
void reject(in optional DOMString message); // explicitly rejects incoming call

-->
void close(); // disconnects and stops listening
};

[Constructor(in DOMString address)] // pass it the result of getAddress() from the other peer
[Constructor]
interface <dfn id=peertopeerclient>PeerToPeerClient</dfn> : <a href=#abstractpeer>AbstractPeer</a> {
void <span title=dom-PeerToPeerClient-addConfiguration>addConfiguration</span>(in DOMString configuration);
void close(); // disconnects
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn id=peertopeerconfigurationcallback>PeerToPeerConfigurationCallback</dfn> {
void <span title=dom-PeerToPeerConfigurationCallback-handleEvent>handleEvent</span>(in <a href=#peertopeerserver>PeerToPeerServer</a> server, in DOMString configuration);
};</pre>

<p class=XXX>...</p>

<div class=XXX>

<p>This relies on some currently hypothetical other standard to
define:</p>

<ul><li>The format of server configuration strings.
<li>The format of client configuration strings.
<li>The protocols that servers and clients use to talk to third-party servers mentioned in the server configuration strings.
<li>The protocols that servers and clients use to talk to each other.
</ul></div>

<div class=example>

<p>Server:</p>

<pre>var serverConfig = ...; // configuration string obtained from server
// contains details such as the IP address of a server that can speak some
// protocol to help the client determine its public IP address, route packets
// if necessary, etc.

var local = new PeerToPeerServer(serverConfig);
local.getClientConfiguration(function (configuration) {
if (configuration != '') {
...; // send configuration to other peer using out-of-band mechanism
} else {
// we've exhausted our options; wait for connection
}
});</pre>

<p>Client:</p>

<pre>var local = new PeerToPeerClient();
function ... (configuration) {
// called whenever we get configuration information out-of-band
local.addConfiguration(configuration);
}</pre>

<p>Both client and server:</p>

<pre>local.onconnect = function (event) {
// we are connected!
local.sendText('Hello');
local.localStream = ...; // send video
local.onstreamchange = function (event) {
// receive video
// (videoElement is some &lt;video&gt; element)
videoElement.src = local.remoteStream.URL;
};
};</pre>

</div>

<p class=warning>To prevent network sniffing from allowing a
fourth party to establish a connection to the
<code><a href=#peertopeerserver>PeerToPeerServer</a></code> using the information sent out-of-band
to the <code><a href=#peertopeerclient>PeerToPeerClient</a></code> and thus spoofing the client,
the configuration information should always be transmitted using an
encrypted connection.</p>




Expand Down
98 changes: 84 additions & 14 deletions source
Expand Up @@ -50493,39 +50493,109 @@ interface <dfn>DataGridListener</dfn> {
<pre class="idl">[NoInterfaceObject]
interface <dfn>AbstractPeer</dfn> {
void sendText(in DOMString text);
attribute Function ontext; // receiving
attribute <span>Function</span> ontext; // receiving

void sendBitmap(in HTMLImageElement image);
attribute Function onbitmap; // receiving
attribute <span>Function</span> onbitmap; // receiving

void sendFile(in File file);
attribute Function onfile; // receiving
attribute <span>Function</span> onfile; // receiving

attribute Stream localStream; // video/audio to send
readonly attribute Stream remoteStream; // video/audio from remote peer
attribute Function onstreamchange; // when the remote peer changes whether the video is being sent or not
attribute <span>Stream</span> localStream; // video/audio to send
readonly attribute <span>Stream</span> remoteStream; // video/audio from remote peer
attribute <span>Function</span> onstreamchange; // when the remote peer changes whether the video is being sent or not

attribute Function onconnect; // called when the connection is established
attribute Function ondisconnect;
attribute <span>Function</span> onconnect;
attribute <span>Function</span> onerror;
attribute <span>Function</span> ondisconnect;
};

[Constructor]
[Constructor(in DOMString serverConfiguration)]
interface <dfn>PeerToPeerServer</dfn> : <span>AbstractPeer</span> {
DOMString <span title="dom-PeerToPeerServer-getAddress">getAddress</span>(); // returns a string that encodes all the various ways to connect to this peer

attribute Function onincoming; // incoming call detected
void <span title="dom-PeerToPeerServer-getClientConfiguration">getClientConfiguration</span>(in <span>PeerToPeerConfigurationCallback</span> callback);
<!--(doesn't make much sense to not accept it, after going to all the effort of setting it up)
attribute <span>Function</span> onincoming; // incoming call detected
void accept(); // accepts incoming call
void reject(in optional DOMString message); // explicitly rejects incoming call

-->
void close(); // disconnects and stops listening
};

[Constructor(in DOMString address)] // pass it the result of getAddress() from the other peer
[Constructor]
interface <dfn>PeerToPeerClient</dfn> : <span>AbstractPeer</span> {
void <span title="dom-PeerToPeerClient-addConfiguration">addConfiguration</span>(in DOMString configuration);
void close(); // disconnects
};

[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn>PeerToPeerConfigurationCallback</dfn> {
void <span title="dom-PeerToPeerConfigurationCallback-handleEvent">handleEvent</span>(in <span>PeerToPeerServer</span> server, in DOMString configuration);
};</pre>

<p class="XXX">...</p>

<div class="XXX">

<p>This relies on some currently hypothetical other standard to
define:</p>

<ul>
<li>The format of server configuration strings.
<li>The format of client configuration strings.
<li>The protocols that servers and clients use to talk to third-party servers mentioned in the server configuration strings.
<li>The protocols that servers and clients use to talk to each other.
</ul>

</div>

<div class="example">

<p>Server:</p>

<pre>var serverConfig = ...; // configuration string obtained from server
// contains details such as the IP address of a server that can speak some
// protocol to help the client determine its public IP address, route packets
// if necessary, etc.

var local = new PeerToPeerServer(serverConfig);
local.getClientConfiguration(function (configuration) {
if (configuration != '') {
...; // send configuration to other peer using out-of-band mechanism
} else {
// we've exhausted our options; wait for connection
}
});</pre>

<p>Client:</p>

<pre>var local = new PeerToPeerClient();
function ... (configuration) {
// called whenever we get configuration information out-of-band
local.addConfiguration(configuration);
}</pre>

<p>Both client and server:</p>

<pre>local.onconnect = function (event) {
// we are connected!
local.sendText('Hello');
local.localStream = ...; // send video
local.onstreamchange = function (event) {
// receive video
// (videoElement is some &lt;video> element)
videoElement.src = local.remoteStream.URL;
};
};</pre>

</div>

<p class="warning">To prevent network sniffing from allowing a
fourth party to establish a connection to the
<code>PeerToPeerServer</code> using the information sent out-of-band
to the <code>PeerToPeerClient</code> and thus spoofing the client,
the configuration information should always be transmitted using an
encrypted connection.</p>

<!--END html-device--><!--START w3c-html-->


Expand Down

0 comments on commit 58d888e

Please sign in to comment.