I would like to build a simple chat app with electron. I wrote a node chat app before using web sockets. Now for a desktop app, I'm wondering how to do networking.
As far as I can see, I have two options: using node's net module, or going through http and actually running a web server as a "chat server".
I guess http has the advantage of being less low-level and more familiar to me, on the other hand I'm wondering if it's not overkill...
Any sugestions?
Related
I am trying to develop a flutter chat app using nodejs and socketio.i'm just getting started with the socketio i have surf several examples in which every front end or client side having a set of socketio script. Can i develop my code purely server side? so that i can integrate with any type of front end.
You can do that. Socket.io is a web socket implementation in node js. It enables real-time, bidirectional and event-based communication between client and server.
Server and client can send and receive the events. If you don't want write any script in client side then you don't have any use of sockets.
Edit:
socket.io given nice example for chat application with explanation. https://socket.io/get-started/chat/
Socket.io has two distinct parts - the server and the client. The docs make this clear. There is nothing preventing you from just writing the server part, and leaving the client implementation out of the equation, for someone else to implement.
Although the main point of Socket.io is to implement the WebSocket protocol, it does so by wrapping it in its own interface, so to speak. So a socket.io server can only talk to socket.io clients, not clients that implement WebSocket in other ways. That being said, there are socket.io client libraries for pretty much every major language out there:
Javascript (main client)
Java
C++
Dart/Flutter
You also asked about React and Angular, but both of those are web front-ends, so there should be no reason why they can't use the standard Javascript client library with those frameworks.
I've used Apache Kafka in my project and need it integrated inside a react-native app which is also part of the project. Basically, my server is a Kafka producer and the app needs to listen to topics and be a consumer.
At first, I tried using this npm package. https://github.com/SOHU-Co/kafka-node.
But this package relies on core modules of nodejs that are not part of the React Native bundle. Is there any other way so as I could communicate using Kafka inside a React Native app?
Thanks!
A quick solution would be to put the Kafka cluster behind a simple REST API. Using a library like kafka-rest could be an easy way to connect your React Native app using the built in fetch function. You could go a step further and try to integrate the kafka-rest-node client into your React Native app; a cursory overview of the repo doesn't lead to any core Node dependencies.
Another method, one which would allow for "live" updates, might consist of putting Kafka behind a web server that converts the Kafka stream into a WebSocket connection. Libraries such as kafka-websocket allow clients to both consume and produce, whereas a more simple library like Microsoft's kafka-proxy-ws only allows for consuming messages.
It's worth noting that mobile clients don't always work well with streaming data, and you'd be advised to test your WebSocket-based implementation on a variety of uncertain network conditions (latency, dropped signals, etc).
Try DeepstreamIO.
It's a real-time socket server that integrates well with both React-Native and Kafka. It can use Kafka as a message broker to communicate messages between distributed Deepstream nodes and push messages to other subscribed clients. They are open source so you can configure their connectors to your specific needs.
I want to add a chat app to my e-commerce website which offers one-to-one chat between the buyers and the sellers. After searching ,web sockets seems to be right for this but it requires node.js server and the rest of my website is in php with apache server. I have read that it is not good to run both apache and node server at the same time. For video chat I'm using appear.in's javascript api which has no such limitations.
How can I run the node.js app under this scenario?
There are plenty of web socket libraries for PHP, e.g. Ratchet.
If this is the only reason for you to move parts of you application to Node.js, you shouldn't necessarily do it.
I am trying to build a desktop app using electron that retrieves mail from a specific mailbox (microsoft exchange server), now, i have looked around and read that mailbox connection should be done server side (the question was made by a guy building a web based app that is a little bit similar to what i want to do), but, since i am not really deploying a node js server but rather using electron, which, as far as i understand is like a desktop app version of node, im not sure on which approach to take. Should i use an api? does microsoft has any interface for this? or should i use a third party integration for it?
It looks like the Exchange Web Services API is only provided as a CLR assembly, so if you wanted to use it you'd need to:
write a C# console app that you then spawn from your Electron app
(and communicate via stdin/stdout), or
use the EWS API in your Electron app via Edge.js
Alternatively, you could probably just directly communicate with the exchange server using SOAP messages, but that could be a bit tedious to implement.
I've googled for few days, some tutorials talking about using ember-cli to build an ember app, but most of them are teaching me to separate the server into two.
That is, one for providing the API endpoint to query the database (with custom express server, mongoDB...), and one for hosting the website (with ember-cli), it means that I have to start two node.js backend servers to serve one website.
Can I do it in one node.js app?
Yes, the only limit to how many "sites" you can run in a single node.js app is based on the hardware of your server. Even the smallest of servers should be able to handle running your api + the website endpoints in one node.js app.
However, what you have isn't two node.js apps, you have an express.js api, and then an ember-cli webapp. It isn't built in such a way that it would be easy to simply consume your ember-cli webapp with your api or the other way around, so i'd have to go with "Yes, it is probably possible", however, good luck making it happen.
I would avoid trying to combine them.