• Public
  • Public/Protected
  • All

Interface Session

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.

You get one of these from a Matcher - a Dialog or DialogOpener on the client side or ServiceRequest on the poppy side - by calling the Matcher.match method.

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.


  • Session



Optional accepting

accepting: undefined | string

What we're accepting from the peer, if we're accepting


closed: Promise<undefined>

A promise that resolves after the session is closed.

Optional hint

hint: undefined | object

The hint the peer provided to us for our match


matchlist: MatchOption[]

The full matchlist sent to us by the peer

Optional offering

offering: undefined | string

What we're offering the peer, if we're offering

Optional opener

opener: Matcher

The thing that created us


origin: string

The origin of the peer


port: MessagePort

The MessagePort to talk to the peer with



  • cancel(): void
  • Forcibly close the session

    Returns void


  • release(): void
  • A "soft" close to signal the primary exchange is done

    Returns void

Generated using TypeDoc