Re: [presentation-api] Add a PresentationConnection.disconnected state for accidental disconnections

Since the only state change that would need further explanation is the
 one that transitions from connected to closed, what about firing a 
separate `CloseEvent` with a result code, similar to WebSockets? [1]  
We could use this to also convey the last message sent if the socket 
closed with a write error, which would resolve #149 and no longer 
require a separate `error` event.

Specific proposal:

```
partial interface PresentationConnection : EventTarget {
    attribute EventHandler                onclosed;
}

enum PresentationConnectionCloseReason {
    "user_requested",   // User navigated, closed tab
    "page_requested",  // Page called .close()
    "send_error",          // Failed to send a message
    "read_error"           // Unable to read further messages
}

[Constructor(DOMString type, PresentationConnectionCloseEventInit 
eventInitDict)]
interface PresentationConnectionCloseEvent : Event {
    [SameObject]
    readonly attribute PresentationConnectionCloseReason closeReason;
    // Includes the message that failed to be sent if closeReason == 
"send_error"
    readonly attribute DOMString errorMessage;
};

dictionary PresentationConnectionAvailableEventInit : EventInit {
  PresentationConnectionCloseReason closeReason;
  DOMString errorMessage;
};
```

[1] https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent

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

Received on Tuesday, 10 November 2015 19:23:15 UTC