A Connection to a peer webpage.
If you're a client, that means a poppy service that's been opened up in a
Dialog. If you're a poppy service, that means the client page that
opened you. Armed with a
MessagePort (see Session.port) and
matching protocol (see Session.accepting and Session.offering)
you should have everything you need to establish a connection. And if it turns
out you don't and need to bail, there's always Session.cancel.
It's called a "session" and not a "connection" because it may stay open after you finish your exchange and are effectively disconnected. The general rule is the poppy closes the session since the poppy has control over the UI, so if you're the client all you do is wait until that happens (you can use the Session.closed promise for that).
That's also why there's a Session.cancel method instead of a
close(). Closing the
session is basically what
cancel() does, but you're generally not supposed to
call it unless something bad happens.
Note that the "poppy closes the session" rule still applies if the poppy is the one to cancel.
But you still should indicate you're done somehow. That's what the Session.release method is for. It's effectively a no-op right now but should come in handy if direct client-to-client connections are implemented - in that case there's no poppy to drive the UI so one of the clients needs to say the session is ready to be closed. Note only one client should do that--which one should be defined based on the protocol being used.
What we're accepting from the peer, if we're accepting
A promise that resolves after the session is closed.
The hint the peer provided to us for our match
The full matchlist sent to us by the peer
What we're offering the peer, if we're offering
The thing that created us
The origin of the peer
MessagePort to talk to the peer with
Forcibly close the session
A "soft" close to signal the primary exchange is done
Generated using TypeDoc