Skip to content

Commit

Permalink
Renamed postMessage() to send() to align with WebRTC DataChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
avayvod committed Apr 2, 2015
1 parent a808fab commit bb065d7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 70 deletions.
60 changes: 28 additions & 32 deletions Overview.src.html
Expand Up @@ -555,7 +555,7 @@ <h3>
castBtn.style.display = evt.available ? "inline" : "none";
};
&lt;/script&gt;

</pre>
</section>
<section>
Expand All @@ -567,7 +567,7 @@ <h3>
&lt;script&gt;
// it is also possible to use relative presentation URL e.g. "presentation.html"
var presUrl = "http://example.com/presentation.html";
// create random presId
// create random presId
var presId = Math.random().toFixed(6).substr(2);
// Start new session. presId is optional.
navigator.presentation.startSession(presUrl, presId)
Expand All @@ -585,7 +585,7 @@ <h3>
<pre class="example">
&lt;!-- controller.html --&gt;
&lt;script&gt;
// read presId from localStorage if exists
// read presId from localStorage if exists
var presId = localStorage &amp;&amp; localStorage["presId"] || null;
// presId is mandatory for joinSession.
presId &amp;&amp; navigator.presentation.joinSession(presUrl, presId)
Expand Down Expand Up @@ -622,7 +622,7 @@ <h3>
console.log("receive message",msg);
};
// send message to presentation page
session.postMessage("say hello");
session.send("say hello");
}
};
var endSession = function () {
Expand All @@ -643,7 +643,7 @@ <h3>
};
session.onmessage = function (msg) {
if (msg == "say hello")
session.postMessage("hello");
session.send("hello");
};
&lt;/script&gt;
</pre>
Expand Down Expand Up @@ -718,7 +718,7 @@ <h3>
session.onstatechange = function() {
switch (session.state) {
case 'connected':
session.postMessage(/*...*/);
session.send(/*...*/);
session.onmessage = function() { /*...*/ };
break;
case 'disconnected':
Expand Down Expand Up @@ -798,7 +798,7 @@ <h4>
and state handling. Initially, the state of the
<code>PresentationSession</code> is <code>"connected"</code>. At this
point, the <span>opening browsing context</span> can communicate with
the presentation page using the session's <code>postMessage()</code>
the presentation page using the session's <code>send()</code>
to send messages and its <code>onmessage</code> event handler to
receive messages. The presentation page will also have access to
<code>PresentationSession</code> that it can use to send and receive
Expand Down Expand Up @@ -909,7 +909,7 @@ <h3>
if (navigator.presentation.session) {
var session = navigator.presentation.session;
// Communicate with opening browsing context
session.postMessage(/*...*/);
session.send(/*...*/);
session.onmessage = function() {/*...*/};
session.onstatechange = function() {
Expand All @@ -928,7 +928,7 @@ <h3>
session. This session is a similar object as in the first example.
Here, its initial state is <code>"connected"</code>, which means we
can use it to communicate with the <span>opening browsing
context</span> using <code>postMessage()</code> and
context</span> using <code>send()</code> and
<code>onmessage</code>.
</p>
<p>
Expand Down Expand Up @@ -1040,15 +1040,13 @@ <h3>
attribute BinaryType <dfn title="binarytype-attribute">binaryType</dfn>;
<span data-anolis-spec="w3c-html">EventHandler</span> <dfn title=
"presentation-onmessage">onmessage</dfn>;
void <dfn>postMessage</dfn> (<span data-anolis-spec=
void <dfn>send</dfn> (<span data-anolis-spec=
"webidl">DOMString</span> message);
void <dfn title="postMessage-blob">postMessage</dfn> (<span data-anolis-spec=
void <dfn title="send-blob">send</dfn> (<span data-anolis-spec=
"fileapi">Blob</span> data);
void <dfn title=
"postMessage-arraybuffer">postMessage</dfn> (<span data-anolis-spec=
void <dfn title="send-arraybuffer">send</dfn> (<span data-anolis-spec=
"typedarray">ArrayBuffer</span> data);
void <dfn title=
"postMessage-arraybufferview">postMessage</dfn> (<span data-anolis-spec=
void <dfn title="send-arraybufferview">send</dfn> (<span data-anolis-spec=
"typedarray">ArrayBufferView</span> data);
};

Expand All @@ -1064,10 +1062,10 @@ <h3>
depending on connection state.
</p>
<p>
When the <code><span>postMessage</span>()</code> method is called on
a <code>PresentationSession</code> object with a
<code>message</code>, the user agent must run the algorithm to
<span title="algorithm-post-message">post a message through a
When the <code><span>send</span>()</code> method is called on a
<code>PresentationSession</code> object with a <code>message</code>,
the user agent must run the algorithm to <span title=
"algorithm-send">send a message through a
<span><code>PresentationSession</code></span></span>.
</p>
<p>
Expand All @@ -1083,17 +1081,17 @@ <h3>
<section>
<p class="open-issue">
<a href="https://github.com/w3c/presentation-api/issues/46">ISSUE
46: Define postMessage behavior</a>
46: Define send behavior</a>
</p>
<h4>
Posting a message through <code>PresentationSession</code>
Sending a message through <code>PresentationSession</code>
</h4>
<p class="note">
Presentation API does not mandate a specific protocol for the
connection between the <span>opening browsing context</span> and
the <span>presenting browsing context</span> except that for
multiple calls to <code>postMessage</code> it has to be ensured
that messages are delivered to the other end in sequence.
multiple calls to <code>send</code> it has to be ensured that
messages are delivered to the other end in sequence.
</p>
<p>
Let <dfn>presentation message data</dfn> be the payload data to be
Expand All @@ -1102,9 +1100,9 @@ <h4>
<code>text</code> and <code>binary</code>.
</p>
<p>
When the user agent is to <dfn title="algorithm-post-message">post
a message through a <code>PresentationSession</code> S</dfn>, it
must run the following steps:
When the user agent is to <dfn title="algorithm-send">send a
message through a <code>PresentationSession</code> S</dfn>, it must
run the following steps:
</p>
<ol>
<li>If the <code>state</code> property of
Expand All @@ -1120,14 +1118,12 @@ <h4>
<li>Assign the <dfn>destination browsing context</dfn> as follows:
<ol>
<li>Let the the <span>destination browsing context</span> be
the <span>opening browsing context</span> if
<span>postMessage</span> is called in the <span>presenting
browsing context</span>.
the <span>opening browsing context</span> if <span>send</span>
is called in the <span>presenting browsing context</span>.
</li>
<li>Let <span>destination browsing context</span> be the <span>
presenting browsing context</span> if
<span>postMessage</span> is called from the <span>opening
browsing context</span>.
presenting browsing context</span> if <span>send</span> is
called from the <span>opening browsing context</span>.
</li>
</ol>
</li>
Expand Down
63 changes: 30 additions & 33 deletions index.html
Expand Up @@ -268,8 +268,8 @@ <h2 class="no-num no-toc" id="table-of-contents">
Interface <code>PresentationSession</code>
</a>
<ol>
<li><a href="#posting-a-message-through-presentationsession"><span class="secno">6.3.1 </span>
Posting a message through <code>PresentationSession</code>
<li><a href="#sending-a-message-through-presentationsession"><span class="secno">6.3.1 </span>
Sending a message through <code>PresentationSession</code>
</a></li>
<li><a href="#receiving-a-message-through-presentationsession"><span class="secno">6.3.2 </span>
Receiving a message through <code>PresentationSession</code>
Expand Down Expand Up @@ -630,7 +630,7 @@ <h3 id="monitor-availability-of-presentation-displays-example"><span class="secn
castBtn.style.display = evt.available ? "inline" : "none";
};
&lt;/script&gt;

</pre>
</section>
<section>
Expand All @@ -641,7 +641,7 @@ <h3 id="starting-a-new-presentation-session-example"><span class="secno">5.2 </s
&lt;script&gt;
// it is also possible to use relative presentation URL e.g. "presentation.html"
var presUrl = "http://example.com/presentation.html";
// create random presId
// create random presId
var presId = Math.random().toFixed(6).substr(2);
// Start new session. presId is optional.
navigator.presentation.startSession(presUrl, presId)
Expand All @@ -658,7 +658,7 @@ <h3 id="joining-a-presentation-session-example"><span class="secno">5.3 </span>
</h3>
<pre class="example">&lt;!-- controller.html --&gt;
&lt;script&gt;
// read presId from localStorage if exists
// read presId from localStorage if exists
var presId = localStorage &amp;&amp; localStorage["presId"] || null;
// presId is mandatory for joinSession.
presId &amp;&amp; navigator.presentation.joinSession(presUrl, presId)
Expand Down Expand Up @@ -694,7 +694,7 @@ <h3 id="monitor-session's-state-and-exchange-data-example"><span class="secno">5
console.log("receive message",msg);
};
// send message to presentation page
session.postMessage("say hello");
session.send("say hello");
}
};
var endSession = function () {
Expand All @@ -714,7 +714,7 @@ <h3 id="monitor-session's-state-and-exchange-data-example"><span class="secno">5
};
session.onmessage = function (msg) {
if (msg == "say hello")
session.postMessage("hello");
session.send("hello");
};
&lt;/script&gt;
</pre>
Expand Down Expand Up @@ -789,7 +789,7 @@ <h3 id="monitor-session's-state-and-exchange-data-example"><span class="secno">5
session.onstatechange = function() {
switch (session.state) {
case 'connected':
session.postMessage(/*...*/);
session.send(/*...*/);
session.onmessage = function() { /*...*/ };
break;
case 'disconnected':
Expand Down Expand Up @@ -869,7 +869,7 @@ <h4>
and state handling. Initially, the state of the
<code>PresentationSession</code> is <code>"connected"</code>. At this
point, the <span>opening browsing context</span> can communicate with
the presentation page using the session's <code>postMessage()</code>
the presentation page using the session's <code>send()</code>
to send messages and its <code>onmessage</code> event handler to
receive messages. The presentation page will also have access to
<code>PresentationSession</code> that it can use to send and receive
Expand Down Expand Up @@ -980,7 +980,7 @@ <h3>
if (navigator.presentation.session) {
var session = navigator.presentation.session;
// Communicate with opening browsing context
session.postMessage(/*...*/);
session.send(/*...*/);
session.onmessage = function() {/*...*/};
session.onstatechange = function() {
Expand All @@ -999,7 +999,7 @@ <h3>
session. This session is a similar object as in the first example.
Here, its initial state is <code>"connected"</code>, which means we
can use it to communicate with the <span>opening browsing
context</span> using <code>postMessage()</code> and
context</span> using <code>send()</code> and
<code>onmessage</code>.
</p>
<p>
Expand Down Expand Up @@ -1106,10 +1106,10 @@ <h3 id="interface-presentationsession"><span class="secno">6.3 </span>
// Communication
attribute BinaryType <dfn id="binarytype-attribute" title="binarytype-attribute">binaryType</dfn>;
<a class="external" data-anolis-spec="w3c-html" href="http://www.w3.org/html/wg/drafts/html/master/webappapis.html#eventhandler">EventHandler</a> <dfn id="presentation-onmessage" title="presentation-onmessage">onmessage</dfn>;
void <dfn id="postmessage">postMessage</dfn> (<a class="external" data-anolis-spec="webidl" href="http://heycam.github.io/webidl/#idl-DOMString">DOMString</a> message);
void <dfn id="postmessage-blob" title="postMessage-blob">postMessage</dfn> (<a class="external" data-anolis-spec="fileapi" href="http://dev.w3.org/2006/webapi/FileAPI/#blob">Blob</a> data);
void <dfn id="postmessage-arraybuffer" title="postMessage-arraybuffer">postMessage</dfn> (<a class="external" data-anolis-spec="typedarray" href="http://www.khronos.org/registry/typedarray/specs/latest/#5">ArrayBuffer</a> data);
void <dfn id="postmessage-arraybufferview" title="postMessage-arraybufferview">postMessage</dfn> (<a class="external" data-anolis-spec="typedarray" href="http://www.khronos.org/registry/typedarray/specs/latest/#6">ArrayBufferView</a> data);
void <dfn id="send">send</dfn> (<a class="external" data-anolis-spec="webidl" href="http://heycam.github.io/webidl/#idl-DOMString">DOMString</a> message);
void <dfn id="send-blob" title="send-blob">send</dfn> (<a class="external" data-anolis-spec="fileapi" href="http://dev.w3.org/2006/webapi/FileAPI/#blob">Blob</a> data);
void <dfn id="send-arraybuffer" title="send-arraybuffer">send</dfn> (<a class="external" data-anolis-spec="typedarray" href="http://www.khronos.org/registry/typedarray/specs/latest/#5">ArrayBuffer</a> data);
void <dfn id="send-arraybufferview" title="send-arraybufferview">send</dfn> (<a class="external" data-anolis-spec="typedarray" href="http://www.khronos.org/registry/typedarray/specs/latest/#6">ArrayBufferView</a> data);
};

</pre>
Expand All @@ -1124,10 +1124,9 @@ <h3 id="interface-presentationsession"><span class="secno">6.3 </span>
depending on connection state.
</p>
<p>
When the <code><a href="#postmessage">postMessage</a>()</code> method is called on
a <a href="#presentationsession"><code>PresentationSession</code></a> object with a
<code>message</code>, the user agent must run the algorithm to
<a href="#algorithm-post-message" title="algorithm-post-message">post a message through a
When the <code><a href="#send">send</a>()</code> method is called on a
<a href="#presentationsession"><code>PresentationSession</code></a> object with a <code>message</code>,
the user agent must run the algorithm to <a href="#algorithm-send" title="algorithm-send">send a message through a
<span><code>PresentationSession</code></span></a>.
</p>
<p>
Expand All @@ -1143,17 +1142,17 @@ <h3 id="interface-presentationsession"><span class="secno">6.3 </span>
<section>
<p class="open-issue">
<a href="https://github.com/w3c/presentation-api/issues/46">ISSUE
46: Define postMessage behavior</a>
46: Define send behavior</a>
</p>
<h4 id="posting-a-message-through-presentationsession"><span class="secno">6.3.1 </span>
Posting a message through <a href="#presentationsession"><code>PresentationSession</code></a>
<h4 id="sending-a-message-through-presentationsession"><span class="secno">6.3.1 </span>
Sending a message through <a href="#presentationsession"><code>PresentationSession</code></a>
</h4>
<p class="note">
Presentation API does not mandate a specific protocol for the
connection between the <a href="#opening-browsing-context">opening browsing context</a> and
the <a href="#presenting-browsing-context">presenting browsing context</a> except that for
multiple calls to <a href="#postmessage"><code>postMessage</code></a> it has to be ensured
that messages are delivered to the other end in sequence.
multiple calls to <a href="#send"><code>send</code></a> it has to be ensured that
messages are delivered to the other end in sequence.
</p>
<p>
Let <dfn id="presentation-message-data">presentation message data</dfn> be the payload data to be
Expand All @@ -1162,9 +1161,9 @@ <h4 id="posting-a-message-through-presentationsession"><span class="secno">6.3.1
<code>text</code> and <code>binary</code>.
</p>
<p>
When the user agent is to <dfn id="algorithm-post-message" title="algorithm-post-message">post
a message through a <code>PresentationSession</code> S</dfn>, it
must run the following steps:
When the user agent is to <dfn id="algorithm-send" title="algorithm-send">send a
message through a <code>PresentationSession</code> S</dfn>, it must
run the following steps:
</p>
<ol>
<li>If the <a href="#state"><code>state</code></a> property of
Expand All @@ -1180,14 +1179,12 @@ <h4 id="posting-a-message-through-presentationsession"><span class="secno">6.3.1
<li>Assign the <dfn id="destination-browsing-context">destination browsing context</dfn> as follows:
<ol>
<li>Let the the <a href="#destination-browsing-context">destination browsing context</a> be
the <a href="#opening-browsing-context">opening browsing context</a> if
<a href="#postmessage">postMessage</a> is called in the <a href="#presenting-browsing-context">presenting
browsing context</a>.
the <a href="#opening-browsing-context">opening browsing context</a> if <a href="#send">send</a>
is called in the <a href="#presenting-browsing-context">presenting browsing context</a>.
</li>
<li>Let <a href="#destination-browsing-context">destination browsing context</a> be the <a href="#presenting-browsing-context">
presenting browsing context</a> if
<a href="#postmessage">postMessage</a> is called from the <a href="#opening-browsing-context">opening
browsing context</a>.
presenting browsing context</a> if <a href="#send">send</a> is
called from the <a href="#opening-browsing-context">opening browsing context</a>.
</li>
</ol>
</li>
Expand Down
10 changes: 5 additions & 5 deletions xrefs/presentation.json
@@ -1,7 +1,7 @@
{
"definitions": {
"algorithm-monitor-available": "algorithm-monitor-available",
"algorithm-post-message": "algorithm-post-message",
"algorithm-send": "algorithm-send",
"availablechangeevent": "availablechangeevent",
"availablechangeeventinit": "availablechangeeventinit",
"binarytype": "binarytype",
Expand All @@ -21,10 +21,6 @@
"onmessage": "onmessage",
"onstatechange": "onstatechange",
"opening browsing context": "opening-browsing-context",
"postmessage": "postmessage",
"postmessage-arraybuffer": "postmessage-arraybuffer",
"postmessage-arraybufferview": "postmessage-arraybufferview",
"postmessage-blob": "postmessage-blob",
"presentation": "presentation",
"presentation display": "presentation-display",
"presentation display availability": "presentation-display-availability",
Expand All @@ -36,6 +32,10 @@
"presentationsession": "presentationsession",
"presentationsessionstate": "presentationsessionstate",
"presenting browsing context": "presenting-browsing-context",
"send": "send",
"send-arraybuffer": "send-arraybuffer",
"send-arraybufferview": "send-arraybufferview",
"send-blob": "send-blob",
"startsession": "startsession",
"state": "state"
},
Expand Down

0 comments on commit bb065d7

Please sign in to comment.