I'm making an Ionic app that needs real time data (a few seconds delay is OK) and I want to use Ajax (with or without long polling) because I may not have the resources to use websockets. However, I want to make it easily upgradable to websockets. Since Socket.io uses Ajax as a fallback, is there a way to force it to use Ajax? This way, I can easily upgrade to websockets if I have the resources.
P.s. just confirming, a server can usually support more clients using Ajax than websockets right? (assume 5-10 seconds per Ajax request).
Assuming your backend is node.js,
var socket = require('socket.io')();
and your socket.io version is 0.x:Otherwise the new syntax for socket.io 1.x is: