GithubHelp home page GithubHelp logo

Introduce `send` callback about engine.io HOT 3 CLOSED

socketio avatar socketio commented on July 18, 2024
Introduce `send` callback

from engine.io.

Comments (3)

rauchg avatar rauchg commented on July 18, 2024

Writing an explanation here since Afshin asked of what we need to do to make this happen.

Basically when a Socket is holding a buffer, we want to tell the transport to write that buffer. Meanwhile, while the transport is writing it (for example, polling might have to wait for an incoming poll GET request), this buffer could grow at the socket level.

The socket will fire this callback when the drain event is executed by the transport, which means the message was sent successfully. The extra complication is that while we're waiting on this event two other events can be emitted by the transport that should clean up this event: error or close. For example, the client might not re-open a GET request, triggering a timeout and a close. Or the write could fail and an error is emitted followed by a close (see websocket write callback).

The other extra complication is that we need to keep track of callbacks even when the transport is not writable yet (when things just get buffered at the socket).

FInally, it'd be cool to emit an event when the socket is closed and things didn't get flushed out (basically when a writeBuffer has items).

from engine.io.

afshinm avatar afshinm commented on July 18, 2024

Thanks @guille, I'll start implementing this one right now.

from engine.io.

rauchg avatar rauchg commented on July 18, 2024

Also important is to consider

#59

Basically instead of always assuming that things are going to be handled well by the transport and resetting the writeBuffer, we should keep track of the length of the writeBuffer in the closure that's being passed down to the transport, then slice the writeBuffer it it succeeds (because it could keep growing after we commit that buffer to the transport)

from engine.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.