Realtime application - alternative for socket.io (node.js) - node.js

I use node.js.
I am looking for an alternative for socket.io.
I need to send a private message to the user.
What is the alternative for the SOCKET.IO?

You haven't really explained why you're looking for Socket.IO. If you provide more details into why Socket.IO isn't working for you then you can get a better answer. Otherwise I'll just point you to a duplicate of this question.
Node.JS Looking for an alternative to socket.IO

Related

Database changes notifications (Angular4 client, NodeJS server)

I'm developing an Angular 4 app that connects to a REST API developed in NodeJS/Express/MySQL. I'm looking for a way to notify any connected clients when there is a change in the database, so they reload their datasets. I've done some searches on Google but I don't know the technical term of what I'm looking for, so I didn't find anything useful.
Can someone point me some resource on this subject? Thanks!
You have two options avaliable
1)HTML5 serversent events
A server-sent event is when a web page automatically gets updates from
a server.
https://www.w3schools.com/html/html5_serversentevents.asp
2)Socket.io
https://socket.io/
Based on my experience for simple realtime updates HTML5 server sent is enough
If you want to visualize changes "live", you should try websockets.
With websockets you could notify any client about any upcoming changes in data, think of it as some kind of chat between server and clients.
There's socket.io for Node.js developers and plenty of tutorials about how to set it up and get it running.
Thanks!
Time to learn some new things... I think I'll start with HTML5 Server Send Events, I think it'll be more than enough for what I need.
Cheers,

Can we send the data from one nodejs app to another nodejs app using MQTT module?

Normally, MQTT module is used to send messages for communication purpose. I am a beginner in nodejs programming. Am I able to send the data from one node app to another app using MQTT module? If it is possible can anyone tell me
how to do so?
Yes, it is possible.
Client: https://github.com/mqttjs/MQTT.js
Server: https://github.com/mcollina/mosca
Take at look at their documentation. They have great examples.

What is the best framework and difference of nodejs framework

These days I try to develop real time application using nodejs.
That application want to update the dashboard according to api data.
I installed express and faye and try to compare what is the best and what are the differences of that two.
As I know express is a node base framework and faye is a subscriber/publisher based one.
But I think both are almost same and anyone can help me to identify the differences?
What is fast and what can be done using the frameworks like that ?
Thanks in advance.
They are not very comparable. If you want to create a real-time application, you will probably need to use both.
Express is a web framework. You will need it to serve and handle HTTP requests and responses. It will help you handle things like url routing, request/response handling middleware, interfacing with template engines, etc... Express is as fast as you'll get.
Faye is a pub sub messaging system- It will not be capable of handling standard HTTP requests and responses. You may be able to implement a live stream of the data using Faye, however, you will still have the need to serve up your client side application using Express.
I would also look into Socket.io as an alternative to Faye- in addition to Express.

How to send a message to node.js server?

How would I send a command to Node.js
I have a jquery / javascript page which detects on keypress W,A,S Or D and then triggers an event to change the canvas.
The next step in this is to then trigger a event on a Node.js server using (I think) Websockets.
Most tutorials I have found are the other way around with sending data to the client.
Does anyone have places with tutorials on how I would do this?
Thanks - Ryan
Use web sockets, tutorial is here http://socket.io/
You can do this with normal ajax calls to Node.js. If you want something more fancy checkout socket.io.

Send messages to specific socket without socket.io in node.js

I'd like to send messages through a socket to specific clients but can't seem to figure out how to do it without socket.io. The reason I can't use socket.io is because I'm trying to connect to a flash client, and I've read in numerous threads here on stackoverflow that socket.io isn't meant to connect to a flash clent. I have working code that will connect a node socket server to a socket client created in flash (actionscript 3), but it broadcasts the info to everyone connected to the socket. What I thought was if there was some way to send info to specific socket ids then I'd be in business. I looked in the docs and didn't find any info on how to do this, but then again I couldn't find any documentation about specific socket ids in the docs either, yet using "socket.id" will give the id so I'm wondering if there is some undocumented way to do this.
And just FYI this is for a card game where each player connected just gets their cards sent to them. The game logic is taken care of server side and I have that working. Now I just need to get each player only the info they need. Thanks.
Darryl
I know for sure you can use Adobe® Flash® Socket in conjunction with socket.io. When you look at the available transports(browsers) you will notice that socket.io also supports Adobe® Flash® Socket. But to be honest I do not know the exact details about this, but I think you can learn them by studying socket.io's specification page.
When looking at socket.io's WIKI I also found there already is a library to use socket.io with Adobe® Flash® Socket. The library is called FlashSocket.IO which I believe can help you although I don't know any flash myself.
Adobe® Flash® Socket is standard disabled in the latest socket.io branches, but you can enable them easily by studying configuring socket.io. This page tells you how to enable all tranports which I will summarize below:
io.set('transports', [ // enable all transports (optional if you want flashsocket)
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
If you have not yet had suffice answer(I think this should help you) I think you could also file an issue at socket.io's issue page, because I find the socket.io's maintainers are super friendly and will tell you how to accomplish this without the least pain.
Finally to accomplish this using plain node you will have to keep track of all the active socket connections(sessions) yourself and only send that message to that specific socket. This is a mundane task, but I think there are more than enough tutorials available that teach you this(you could also look at socket.io how they achieve this, although this is a pretty large project/codebase).
I hope this answered your question. If not, I recommend you to ask a question in the comments for example.

Resources