简体   繁体   中英

Best structure for developing a messaging server

I'm developing an app that will have a way to message other users. I've done this before but I think I can improve on the method of sending/receiving the data. Before what I did is I had a table with all the messages and the ones that were associated with the conversation ID would be displayed in an individual conversation. On the client side, I'd have a timer that would constantly ask the server for an update.

I guess my question is this: Is there a better way than to keep asking my server if there is an update? I mean.. a lighter way. I was considering using push notifications but if the user disables APNS, their messages won't update.

http://reactphp.org/

Is useful for event driven socket based communication. It would involve storing connected clients in some kind of data structure ( see here ) and on an event, such as a change to data, notifying connected clients that should know about the event, in the manner of a push.

http://socketo.me/ is built on top of react

http://socketo.me/docs/flow

has a good diagram of how socket based connections work. This might be better than polling repeatedly from all the connected clients, based on your use case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM