Re: [presentation-api] Define behavior when sending a message to a PresentationSession fails

@mounirlamouri:

> I would be in favour of not automatically close and let the web page
 make that decision.

We would need to add a means for the page to terminate its session 
(but not the underlying presentation), i.e. a 
`PresentationSession.disconnect()` method.  

>  Regarding promise vs. event, I would prefer using a promise because
 it makes it clearer the error is about the message sending and it 
allows different error handling depending on the send() call.

This makes the code for sending multiple messages in sequence feel odd
 and less performant:

```
var s = theSession;
s.send("first-message").then(s.send("second-message"), 
disconnectSession(s)).then(
```
In this code, the second message can't be queued until delivery of the
 first message succeeds.  This also means a separate event loop/task 
for each message in a sequence.  Perhaps we could rewrite the `send` 
API to take sequences of messages?  But would that negate the proposed
 advantage of having one Promise per message?

Or what would happen if:

```
session.send("first-message");
session.send("second-message");
```
Would these messages get sent if no resolver is provided?

---

Idea: as suggested, would an exception attached to send() be better 
than an `error` event?  That way the caller knows which invocations of
 `send()` failed and we don't have to provide message details in the 
event.



-- 
GitHub Notif of comment by mfoltzgoogle
See 
https://github.com/w3c/presentation-api/issues/149#issuecomment-125460997

Received on Tuesday, 28 July 2015 06:06:35 UTC