Git Product home page Git Product logo

Comments (4)

siegesmund avatar siegesmund commented on August 25, 2024

When you pass a callback to the connection method that callback is executed after the server sends a successful connection message. That's how you know when it's connected.

Disconnection is trickier. There is no DDP message for 'disconnect'. Rather, the client and server may exchange pings to make sure that one another are still there. If too long an interval passes without receiving a ping response, the server will close the connection.

If the connection closes, SwiftDDP automatically tries reestablish the connection. This is analogous to the way DDP works in the browser (MeteorJS). The connection is designed to happen in the background, independent of the application code, and to be managed by the server.

So, for the initial connection, use the callback. As for disconnection, it should not happen unless your server closes the connection because it can no longer reach your client.

from swiftddp.

PIRDev avatar PIRDev commented on August 25, 2024

Thank you for the quick reply. However, what I need in my application is to deactivate users' interactions when meteor is disconnected and reactivate when it's reconnected. Therefore, the call back function after calling "connect" is only useful if I connect to meteor manually, but I need to handle the auto-reconnect as well.

Is there a way to listen to onConnect and onDisconnect?

from swiftddp.

siegesmund avatar siegesmund commented on August 25, 2024

No.

Consider what happens when you use Meteor in the browser. You, as the developer, do not control the connection. It happens automatically in the background. You control access to the app in other ways, via authentication, authorization, subscriptions etc. SwiftDDP mimics this approach, with one exception, which is that you have to manually initiate the initial connection.

from swiftddp.

siegesmund avatar siegesmund commented on August 25, 2024

Closing this... please reopen or open a new issue of this isn't clear.

from swiftddp.

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.