simple-xmpp / node-simple-xmpp

Simple High Level NodeJS XMPP Client
302 stars 90 forks source link

Architecture for multi-client application #84

Closed shubham1172 closed 5 years ago

shubham1172 commented 5 years ago

Hey, for an instant messaging application with multiple clients, should one create multiple instances of XMPP clients? What is the best way to deal with this use case?

silverbucket commented 5 years ago

Correct, you should create a new instance for each account.

shubham1172 commented 5 years ago

What'll be the best way to store an instance of XMPP client per user in the memory? Express-session or redis cannot save objects like these, I suppose :/

silverbucket commented 5 years ago

Yeah, you will need to have some sort of daemon which maintains the connection as long as you need to keep it open. You cannot store network connections like you can with normal objects as they require system resources to stay active. This is something I've been working on with github.com/sockethub/sockethub which abstracts protocol specifics, as well as maintaining state, away from web applications. It may not suit your needs, but might provide some inspiration for your use case, but I can't really provide any more suggestions without knowing more.