Skip to content

Commit

Permalink
[] (0) There's not really any point talking about separate Client and…
Browse files Browse the repository at this point in the history
… Server objects here. Both will have to send config information back and forth to make the connection work anyway.

git-svn-id: http://svn.whatwg.org/webapps@4988 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Apr 9, 2010
1 parent fb17129 commit d6b574c
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 137 deletions.
83 changes: 37 additions & 46 deletions complete.html
Expand Up @@ -186,7 +186,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; 8 April 2010</h2>
<h2 class="no-num no-toc">Draft Standard &mdash; 9 April 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 @@ -46646,7 +46646,8 @@ <h5 id=peer-to-peer-connections><span class=secno>4.11.6.2 </span>Peer-to-peer c
<code><a href=#devices>device</a></code> element to allow reviewers to look at it.</p>

<pre class=idl>[NoInterfaceObject]
interface <dfn id=abstractpeer>AbstractPeer</dfn> {
[Constructor(in DOMString serverConfiguration)]
interface <dfn id=connectionpeer>ConnectionPeer</dfn> {
void sendText(in DOMString text);
attribute <a href=#function>Function</a> ontext; // receiving

Expand All @@ -46656,35 +46657,24 @@ <h5 id=peer-to-peer-connections><span class=secno>4.11.6.2 </span>Peer-to-peer c
void sendFile(in File file);
attribute <a href=#function>Function</a> onfile; // receiving

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
void addStream(in Stream stream);
void removeStream(in Stream stream);
readonly attribute Stream[] localStreams;
readonly attribute Stream[] remoteStreams;
attribute <a href=#function>Function</a> onstream; // receiving

void <span title=dom-ConnectionPeer-getLocalConfiguration>getLocalConfiguration</span>(in <a href=#connectionpeerconfigurationcallback>ConnectionPeerConfigurationCallback</a> callback); // maybe this should be in the constructor
void <span title=dom-ConnectionPeer-addRemoteConfiguration>addRemoteConfiguration</span>(in DOMString configuration);
void close(); // disconnects and stops listening

attribute <a href=#function>Function</a> onconnect;
attribute <a href=#function>Function</a> onerror;
attribute <a href=#function>Function</a> ondisconnect;
};

[Constructor(in DOMString serverConfiguration)]
interface <dfn id=peertopeerserver>PeerToPeerServer</dfn> : <a href=#abstractpeer>AbstractPeer</a> {
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]
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);
interface <dfn id=connectionpeerconfigurationcallback>ConnectionPeerConfigurationCallback</dfn> {
void <span title=dom-ConnectionPeerConfigurationCallback-handleEvent>handleEvent</span>(in <a href=#connectionpeer>ConnectionPeer</a> server, in DOMString configuration);
};</pre>

<p class=XXX>...</p>
Expand All @@ -46696,57 +46686,58 @@ <h5 id=peer-to-peer-connections><span class=secno>4.11.6.2 </span>Peer-to-peer c

<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.
<li>The protocols that clients use to talk to third-party servers mentioned in the server configuration strings.
<li>The protocols that clients use to talk to each other.
</ul></div>

<div class=example>

<p>Server:</p>
<p>When two peers decide they are going to set up a connection to
each other, they both go through these steps. The serverConfig
comes from a third-party server they can use to get things like
their public IP address or to set up NAT traversal. They also have
to send their respective configuration to each other using the same
out-of-band mechanism they used to establish that they were going
to communicate in the first place.</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) {
var local = new ConnectionPeer(serverConfig);
local.getLocalConfiguration(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>
local.addRemoteConfiguration(configuration);
}

<pre>local.onconnect = function (event) {
local.onconnect = function (event) {
// we are connected!
local.sendText('Hello');
local.localStream = ...; // send video
local.onstreamchange = function (event) {
local.addStream(...); // send video
local.onstream = function (event) {
// receive video
// (videoElement is some &lt;video&gt; element)
videoElement.src = local.remoteStream.URL;
if (local.remoteStreams.length &gt; 0)
videoElement.src = local.remoteStreams[0].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>
fourth party to establish a connection to a peer using the
information sent out-of-band to the other peer and thus spoofing the
client, the configuration information should always be transmitted
using an encrypted connection.</p>



Expand Down
83 changes: 37 additions & 46 deletions index
Expand Up @@ -190,7 +190,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; 8 April 2010</h2>
<h2 class="no-num no-toc">Draft Standard &mdash; 9 April 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 @@ -46547,7 +46547,8 @@ interface <dfn>DataGridListener</dfn> {
<code><a href=#devices>device</a></code> element to allow reviewers to look at it.</p>

<pre class=idl>[NoInterfaceObject]
interface <dfn id=abstractpeer>AbstractPeer</dfn> {
[Constructor(in DOMString serverConfiguration)]
interface <dfn id=connectionpeer>ConnectionPeer</dfn> {
void sendText(in DOMString text);
attribute <a href=#function>Function</a> ontext; // receiving

Expand All @@ -46557,35 +46558,24 @@ interface <dfn id=abstractpeer>AbstractPeer</dfn> {
void sendFile(in File file);
attribute <a href=#function>Function</a> onfile; // receiving

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
void addStream(in Stream stream);
void removeStream(in Stream stream);
readonly attribute Stream[] localStreams;
readonly attribute Stream[] remoteStreams;
attribute <a href=#function>Function</a> onstream; // receiving

void <span title=dom-ConnectionPeer-getLocalConfiguration>getLocalConfiguration</span>(in <a href=#connectionpeerconfigurationcallback>ConnectionPeerConfigurationCallback</a> callback); // maybe this should be in the constructor
void <span title=dom-ConnectionPeer-addRemoteConfiguration>addRemoteConfiguration</span>(in DOMString configuration);
void close(); // disconnects and stops listening

attribute <a href=#function>Function</a> onconnect;
attribute <a href=#function>Function</a> onerror;
attribute <a href=#function>Function</a> ondisconnect;
};

[Constructor(in DOMString serverConfiguration)]
interface <dfn id=peertopeerserver>PeerToPeerServer</dfn> : <a href=#abstractpeer>AbstractPeer</a> {
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]
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);
interface <dfn id=connectionpeerconfigurationcallback>ConnectionPeerConfigurationCallback</dfn> {
void <span title=dom-ConnectionPeerConfigurationCallback-handleEvent>handleEvent</span>(in <a href=#connectionpeer>ConnectionPeer</a> server, in DOMString configuration);
};</pre>

<p class=XXX>...</p>
Expand All @@ -46597,57 +46587,58 @@ interface <dfn id=peertopeerconfigurationcallback>PeerToPeerConfigurationCallbac

<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.
<li>The protocols that clients use to talk to third-party servers mentioned in the server configuration strings.
<li>The protocols that clients use to talk to each other.
</ul></div>

<div class=example>

<p>Server:</p>
<p>When two peers decide they are going to set up a connection to
each other, they both go through these steps. The serverConfig
comes from a third-party server they can use to get things like
their public IP address or to set up NAT traversal. They also have
to send their respective configuration to each other using the same
out-of-band mechanism they used to establish that they were going
to communicate in the first place.</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) {
var local = new ConnectionPeer(serverConfig);
local.getLocalConfiguration(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>
local.addRemoteConfiguration(configuration);
}

<pre>local.onconnect = function (event) {
local.onconnect = function (event) {
// we are connected!
local.sendText('Hello');
local.localStream = ...; // send video
local.onstreamchange = function (event) {
local.addStream(...); // send video
local.onstream = function (event) {
// receive video
// (videoElement is some &lt;video&gt; element)
videoElement.src = local.remoteStream.URL;
if (local.remoteStreams.length &gt; 0)
videoElement.src = local.remoteStreams[0].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>
fourth party to establish a connection to a peer using the
information sent out-of-band to the other peer and thus spoofing the
client, the configuration information should always be transmitted
using an encrypted connection.</p>



Expand Down

0 comments on commit d6b574c

Please sign in to comment.