WebSocket or Periodic Requests in hybrid Apps? - node.js

I am developing an hybrid mobile app that collects some user info in background while the user is calling (just during a phone call). Then I have an admin dashboard on a website, where the admins can monitor the (almost) real-time status of the mobile users. To do this, my mobile app must send info to the server. Right now I just use:
setInterval(sendData, 5000) to send data each 5sec from the mobile app to the server.
setInterval(refreshData, 5000) to request the current status from the admin dashboard to the server.
I don't need a "strong real-time", so it's enough update each 5secs.
Anyway I'd like to know if it's better use web sockets among the mobile app and the server, since the app should send data very often during the day.
Thank you

Related

User authentication / authorization using mobile app or QR code

I would like to build an authentication / authorizaton mobile app that would:
Scenario 1
receive auth requests from web apps when a QR code is scanned
Scenario 2
receive auth requests from web apps when a user tries to login with username
If you know the platform Binance (https://accounts.binance.com/en/login?), you might notice the Scenario 1 I'm describing. As per the second scenario, I would like the user to write its name on an input field and receive a request on a mobile application that is "connected" with the webapp so that the user can willingly authorize oneself by means of a push notification.
Both scenarios require the user to be LOGGED IN in the mobile application, as to prove that they are who they say they are.
As per the technologies I would be using:
nodejs on the backend
react on the frontend
react native / flutter on the mobile
Do you have any resources on the subject?
Thanks

How does a Web Application like Google Hangouts get Client Side Information?

Google Hangouts Web Application has a screen sharing feature and it allows user to select a particular application by providing a list of all applications running in the client machine.
Could somebody explain how this is accomplished? As per my understanding, this cannot be implemented in a typical web application due to security reasons.

RESTful API, tracking client's individual user requests

I have an API set up on my server (node.js) which potential clients can send request to. One such client would like for me to set up a structure where they would pay only for the amount of their users who would connect to my API. They are creating a mobile application. Regardless mobile or web, I'm not sure how I would be able to track their individual users, to make sure it is their users who are sending requests to my server and not the client himself. The client can make one request and send to 1000 of their users instead of 1000 of the client's users directly connecting to my server.
The only feasible solution I can think of is creating a plugin which they would insert into their app and it would connect directly to our server, bypassing the client's server. Something like a Facebook Share/Like, Google +1 button. Creating the plugin would require to create the entire request and dynamic layout in each platform language, which is outside my scope at the moment.
Is there any way to have the end-users connect directly to my server through the client's app, bypassing the client in the middle, allowing me to know how many users will be connecting?

Session Management in servicestack

In the Icenium Hybrid app we have a requirement like we need to keep the logged in user's session active for about 8 hours and then log-out automatically.
The app is connecting to the Servicestack REST services which also handles sessions at the server side.
How do we handle the session management on the device as well as server side?Any examples are highly appreciated.

Can ServiceStack support websockets?

Servicestack is awesome. I'm using it for my Xamarin projects (monotouch and monodroid).
Users login and authorised by ServiceStack. The session details are kept in memory i.e. userId, Ipaddress, etc.
But what would be the best way to add websocket functionality so I could push notifications to these users?
Or would it be better to just leave a regular websocket open on the client and have a small websocket server somehow read the session data (user Ipaddress) from ServiceStack in order to relay bespoke messages to client?
As an alternative to Web Sockets ServiceStack supports Server Sent Events for real-time event notifications. All the Chat Apps in the Live Demos utilizes Server Events for its real-time communication.
But it doesn't include any support for Web Sockets itself, although here's an example of using ServiceStack and SignalR in the same project.

Resources