Giter VIP home page Giter VIP logo

Comments (5)

Atrue avatar Atrue commented on June 12, 2024

@piranna The dispatchEvent function is already called with the delay helper in the websocket. The server event can be called with delay manually in your code.
Can you please give more details of your problem, what the exact place you need the delay?

from mock-socket.

piranna avatar piranna commented on June 12, 2024

Just the part of the server event. I don't want to provide a manual delay on my code, I want the listeners to be executed at least in the next event loop when they are dispatched, not in the same one. This allows me to register some events in the WebSocket, as I would do normally in real code.

from mock-socket.

Atrue avatar Atrue commented on June 12, 2024

Make sense, you can create a PR, but add the delay in the server's methods where it's needed, not in the dispatchEvent;
It would be very helpful if you also provide a test or example that demonstrates the problem

from mock-socket.

piranna avatar piranna commented on June 12, 2024

I think the server method is send(). Why dispatchEvent() is not the correct place? All the server-to-client events are going throught there, so it makes sense to me to add the "network transmission delay" there...

from mock-socket.

Atrue avatar Atrue commented on June 12, 2024

All the events inside the library are going through dispatchEvent. If the event or the code should be delayed it's wrapped using the delay helper. See websocket.js for examples

from mock-socket.

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.