Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Relaxterminate algorithm to deal with other states? #421

Closed
@tidoust

Description

@tidoust

Theterminate method only has an effect on a presentation connection whose state isconnected.

I think a common scenario for callingterminate is when the controlling browsing context is about to disappear or when the user clicks on a button, to clean things up, regardless of the current application state.

This is what we try to do in the test suite for instance, so that subsequent tests start from a clean "no on-going presentation" state. However, sinceterminate only works onconnected presentations, terminating a presentation no matter what turns out to be more complex that simply callingterminate, leading to code such as:

// Try to terminate the presentationconnection.terminate();// If state was "connecting", previous call did nothing,// wait for the "connect" eventconnection.onconnect=()=>{connection.terminate();};// If state was "closed", we need to reconnect first. This will return a// presentation in "connecting" state. Previous event handler will eventually// take care of it if it's the same "connection", but it may not be.if(connection.state==='closed'){request.reconnect(connection.id).then(c=>{c.onconnect=()=>{c.terminate();};});}

I'm wondering whether the user agent could take care of some of that complexity, ideally so that developers can end up with a simpleconnection.terminate() call. This would require relaxing theterminate algorithm so that:

  1. It also applies to connections in theconnecting state. The user agent would wait for the underlying connection to becomeconnected.
  2. It also applies to connections in theclosed state. The user agent would attempt to reconnect the underlying connection before it terminates it.

The latter change may be more problematic, and it seems reasonable to expect applications to deal with connections in theclosed state themselves. The former change seems easier and useful. If both changes are in place, developers can just issue a call toconnection.terminate() and be done with it. If only the former change is in place, developers would have to write something like:

if(connection.state==='closed'){request.reconnect(connection.id).then(c=>{c.terminate();});}else{connection.terminate();}

... which seems acceptable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp