Code Monkey home page Code Monkey logo

Comments (1)

OmarElgabry avatar OmarElgabry commented on July 20, 2024

This already is almost done by Socket.io, but, there are pitfalls.

If two users are chatting together; userA and userB. If userA lost the internet connection, the socket will detect there is a disconnection and will try to reconnect when the connection is up again. Now, any messages that will be sent by userA will be buffered and transmitted to all other active sockets when it's possible.

The problem is, any messages that will be sent by userB during the disconnection, won't be delivered to userA after reconnecting successfully, Why? On re-connection, a new socket will be created, with a new id, and will join the room again, and when userB tried to send messages to all active sockets while userA was disconnected, the newly created socket(created after re-connection) wasn't included across active sockets.

The solution might be for userA has to ask for the messages sent by all users in the chatroom while disconnection. Therefore, the messages has to be stored somewhere for later fetching.

For this chat application, I don't store messages, So, it's hard to achieve this, but, can be implemented in the future.

from chat.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.