RESTful Api or Socket.IO

 ̄綄美尐妖づ 提交于 2019-12-24 03:47:07

问题


Im writing a mobile application. It connects to the node.js server and getting some data. Which is the best way to retrieving data from nodejs server?

My project architecture:

mySQL DB <-> node.js (Server) <--(socket.io or restful)--> mobile clients


回答1:


If you need a bidirectional real-time connection between your server and your client (e.g. a chat bot or a stock ticker), then socket.io would be a good choice.

However if you just need to fetch some data from time to time on the client from the server (and / or push some data), then a RESTful architecture makes more sense.

For most use cases a RESTful architecture is probably better. If you elaborate a bit more about what kind of data you're sharing between the client and the server, there could be a more precise answer.



来源:https://stackoverflow.com/questions/25743402/restful-api-or-socket-io

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!