From bb065d7dfaf35f992eef4d02b58917ca8f46b36d Mon Sep 17 00:00:00 2001 From: Anton Vayvod Date: Thu, 2 Apr 2015 14:04:11 +0100 Subject: [PATCH] Renamed postMessage() to send() to align with WebRTC DataChannel --- Overview.src.html | 60 ++++++++++++++++++--------------------- index.html | 63 ++++++++++++++++++++--------------------- xrefs/presentation.json | 10 +++---- 3 files changed, 63 insertions(+), 70 deletions(-) diff --git a/Overview.src.html b/Overview.src.html index c243096..8adafe4 100644 --- a/Overview.src.html +++ b/Overview.src.html @@ -555,7 +555,7 @@

castBtn.style.display = evt.available ? "inline" : "none"; }; </script> - +
@@ -567,7 +567,7 @@

<script> // 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) @@ -585,7 +585,7 @@

 <!-- controller.html -->
 <script>
-  // read presId from localStorage if exists 
+  // read presId from localStorage if exists
   var presId = localStorage && localStorage["presId"] || null;
   // presId is mandatory for joinSession.
   presId && navigator.presentation.joinSession(presUrl, presId)
@@ -622,7 +622,7 @@ 

console.log("receive message",msg); }; // send message to presentation page - session.postMessage("say hello"); + session.send("say hello"); } }; var endSession = function () { @@ -643,7 +643,7 @@

}; session.onmessage = function (msg) { if (msg == "say hello") - session.postMessage("hello"); + session.send("hello"); }; </script>

@@ -718,7 +718,7 @@

session.onstatechange = function() { switch (session.state) { case 'connected': - session.postMessage(/*...*/); + session.send(/*...*/); session.onmessage = function() { /*...*/ }; break; case 'disconnected': @@ -798,7 +798,7 @@

and state handling. Initially, the state of the PresentationSession is "connected". At this point, the opening browsing context can communicate with - the presentation page using the session's postMessage() + the presentation page using the session's send() to send messages and its onmessage event handler to receive messages. The presentation page will also have access to PresentationSession that it can use to send and receive @@ -909,7 +909,7 @@

if (navigator.presentation.session) { var session = navigator.presentation.session; // Communicate with opening browsing context - session.postMessage(/*...*/); + session.send(/*...*/); session.onmessage = function() {/*...*/}; session.onstatechange = function() { @@ -928,7 +928,7 @@

session. This session is a similar object as in the first example. Here, its initial state is "connected", which means we can use it to communicate with the opening browsing - context using postMessage() and + context using send() and onmessage.

@@ -1040,15 +1040,13 @@

attribute BinaryType binaryType; EventHandler onmessage; - void postMessage (send (DOMString message); - void postMessage (send (Blob data); - void postMessage (send (ArrayBuffer data); - void postMessage (send (ArrayBufferView data); }; @@ -1064,10 +1062,10 @@

depending on connection state.

- When the postMessage() method is called on - a PresentationSession object with a - message, the user agent must run the algorithm to - post a message through a + When the send() method is called on a + PresentationSession object with a message, + the user agent must run the algorithm to send a message through a PresentationSession.

@@ -1083,17 +1081,17 @@

ISSUE - 46: Define postMessage behavior + 46: Define send behavior

- Posting a message through PresentationSession + Sending a message through PresentationSession

Presentation API does not mandate a specific protocol for the connection between the opening browsing context and the presenting browsing context except that for - multiple calls to postMessage it has to be ensured - that messages are delivered to the other end in sequence. + multiple calls to send it has to be ensured that + messages are delivered to the other end in sequence.

Let presentation message data be the payload data to be @@ -1102,9 +1100,9 @@

text and binary.

- When the user agent is to post - a message through a PresentationSession S, it - must run the following steps: + When the user agent is to send a + message through a PresentationSession S, it must + run the following steps:

  1. If the state property of @@ -1120,14 +1118,12 @@

  2. Assign the destination browsing context as follows:
    1. Let the the destination browsing context be - the opening browsing context if - postMessage is called in the presenting - browsing context. + the opening browsing context if send + is called in the presenting browsing context.
    2. Let destination browsing context be the - presenting browsing context if - postMessage is called from the opening - browsing context. + presenting browsing context if send is + called from the opening browsing context.
  3. diff --git a/index.html b/index.html index fc70e34..0b842b4 100644 --- a/index.html +++ b/index.html @@ -268,8 +268,8 @@

    Interface PresentationSession
      -
    1. 6.3.1 - Posting a message through PresentationSession +
    2. 6.3.1 + Sending a message through PresentationSession
    3. 6.3.2 Receiving a message through PresentationSession @@ -630,7 +630,7 @@

@@ -641,7 +641,7 @@

5.2 5.3

<!-- controller.html -->
 <script>
-  // read presId from localStorage if exists 
+  // read presId from localStorage if exists
   var presId = localStorage && localStorage["presId"] || null;
   // presId is mandatory for joinSession.
   presId && navigator.presentation.joinSession(presUrl, presId)
@@ -694,7 +694,7 @@ 

5 console.log("receive message",msg); }; // send message to presentation page - session.postMessage("say hello"); + session.send("say hello"); } }; var endSession = function () { @@ -714,7 +714,7 @@

5 }; session.onmessage = function (msg) { if (msg == "say hello") - session.postMessage("hello"); + session.send("hello"); }; </script>

@@ -789,7 +789,7 @@

5 session.onstatechange = function() { switch (session.state) { case 'connected': - session.postMessage(/*...*/); + session.send(/*...*/); session.onmessage = function() { /*...*/ }; break; case 'disconnected': @@ -869,7 +869,7 @@

and state handling. Initially, the state of the PresentationSession is "connected". At this point, the opening browsing context can communicate with - the presentation page using the session's postMessage() + the presentation page using the session's send() to send messages and its onmessage event handler to receive messages. The presentation page will also have access to PresentationSession that it can use to send and receive @@ -980,7 +980,7 @@

if (navigator.presentation.session) { var session = navigator.presentation.session; // Communicate with opening browsing context - session.postMessage(/*...*/); + session.send(/*...*/); session.onmessage = function() {/*...*/}; session.onstatechange = function() { @@ -999,7 +999,7 @@

session. This session is a similar object as in the first example. Here, its initial state is "connected", which means we can use it to communicate with the opening browsing - context using postMessage() and + context using send() and onmessage.

@@ -1106,10 +1106,10 @@

6.3 // Communication attribute BinaryType binaryType; EventHandler onmessage; - void postMessage (DOMString message); - void postMessage (Blob data); - void postMessage (ArrayBuffer data); - void postMessage (ArrayBufferView data); + void send (DOMString message); + void send (Blob data); + void send (ArrayBuffer data); + void send (ArrayBufferView data); }; @@ -1124,10 +1124,9 @@

6.3 depending on connection state.

- When the postMessage() method is called on - a PresentationSession object with a - message, the user agent must run the algorithm to - post a message through a + When the send() method is called on a + PresentationSession object with a message, + the user agent must run the algorithm to send a message through a PresentationSession.

@@ -1143,17 +1142,17 @@

6.3

ISSUE - 46: Define postMessage behavior + 46: Define send behavior

-

6.3.1 - Posting a message through PresentationSession +

6.3.1 + Sending a message through PresentationSession

Presentation API does not mandate a specific protocol for the connection between the opening browsing context and the presenting browsing context except that for - multiple calls to postMessage it has to be ensured - that messages are delivered to the other end in sequence. + multiple calls to send it has to be ensured that + messages are delivered to the other end in sequence.

Let presentation message data be the payload data to be @@ -1162,9 +1161,9 @@

6.3.1 text and binary.

- When the user agent is to post - a message through a PresentationSession S, it - must run the following steps: + When the user agent is to send a + message through a PresentationSession S, it must + run the following steps:

  1. If the state property of @@ -1180,14 +1179,12 @@

    6.3.1
  2. Assign the destination browsing context as follows:
    1. Let the the destination browsing context be - the opening browsing context if - postMessage is called in the presenting - browsing context. + the opening browsing context if send + is called in the presenting browsing context.
    2. Let destination browsing context be the - presenting browsing context if - postMessage is called from the opening - browsing context. + presenting browsing context if send is + called from the opening browsing context.
  3. diff --git a/xrefs/presentation.json b/xrefs/presentation.json index b3b85c8..fdda7b4 100644 --- a/xrefs/presentation.json +++ b/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", @@ -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", @@ -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" },