Qt Application - node.js server communication - node.js

I want to make a desktop application (since its supposed to be cross-platform, I've decided to stick with Qt, and I am already familiar with it) which connects to a server. The app is similar in concept to a chat application. I know that there are application servers, however as of now, I'm familiar with web server frameworks such as rails, and am trying out node.js currently.
I wanted to know how should I ask my application(Qt-based) to connect to the server, and the main question is, how should I implement the server? After thinking up of various options, including porting the whole project over to as a web-app, I've decided that the best bet would be to use the app to somehow connect to the node.js server and it will serve the html files which will contain the command for the app. Am I on the right path?
Can this (Qt-app & node.js server communication) be achieved in the way I am thinking? Is it the correct method?

It is easy to communicate with node.js app by socket. Using node.js to create a Net server (http://nodejs.org/api/net.html), and client use socket to connect to it. In my opinion it is easier to build a server with Node.js than C/C++ and has nice performance.
BTW, I think using node.js as server has gradually become a common solution. And My company have developed a mobile game with pomelo which is a node.js game framework.
For more infomation you can see this article http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js

Related

What technologies would necessary to connect to a cloud server from a Node.js backend?

I am relatively new to mobile development and would like to know further information about this specific topic.
I am working on a React Native based mobile application and am now getting around to implementing the back-end for this application. I will need to send data back and forth from the client (the mobile application) to the server (a cloud server). I am aware I can accomplish this with technologies such as a MongoDB database or a Firebase database, however, I would like to try to implement this on a personal cloud server.
How would I go about establishing a connection to a server in node.js so that I may send and receive data?
Thus far, I have looked the node library Express.js, but I am unsure if this is of any relevance as to what I am looking for in terms of a solution to what I am trying to achieve.
First of all, I think you need to have a backend project for making your backend you choose Nodejs
Node JS is a fast JavaScript runtime environment that we use to build server-side applications, but it does not know how to perform serving files, handling requests, and handling HTTP methods, so this is where express js comes in.
Express JS is a Node.js framework designed to build API's web applications cross-platform mobile apps quickly and make node js easy.
Why Express JS?
Express was created to make APIs and web applications with ease
It saves a lot of coding time almost by half and still makes web and
mobile applications are efficient.
The reason behind creating an express framework for node js is:
Time-efficient
Fast
Economical
Easy to learn
Asynchronous
After completing your backend project with either postgres or mongodb database connection and node js you can deploy it to your cloud server and access it from the apis form the front end mobile or web applications.
Another thing I want to mention you can also create some web pages using node handlebars as well.

Signaling mechanism for webRTC using simpleWebRTC js library and backend in django

I am trying to build video conferencing web application where multiple people can join the call and there will be video/audio/data transmission. I researched a lot for this. What i understand is we can achieve this using webRTC protocol. I started doing research for js libraries and i came to know for simpleWebRTC. I want to develop with backend as a django. I tried to run sample demo code from https://www.sitepoint.com/webrtc-video-chat-application-simplewebrtc/. but i am not able to establish connection with socket.io which is simplewebRTC signaling sandbox server.
I tried with node express server as well, but still i got the same error:- net::ERR_FAILED. This error occured in simplewebrtc-with-adapter-js while making connection.
What would be the correct technologies to achieve this type of functionality?
Front-end webRTC libraries:- simplewebRTC/ EasyRTC/ Any else apis?
Signaling mechanism:- What and how can we use to connect with webRTC?
Backend:- Node js/Django?
I still confused with the signaling protocols/STUN/TURN servers as we have to define the servers by our self. simpleWebRTC is not providing that which we can use in production.
Any help would be much appreciated!
I just started a video calling and chat application as well. open-easyrtc, no problems so far, their demo just works after npm install.
As for signaling servers, since I just started I haven't concerned myself much about them but the most I can make out of it is it's used for exchanging information like video metadata, network information, etc. open-easyrtc comes with public STUN and TURN servers, not sure about the limitation especially if you're going to have a lot of users.
It's also possible to deploy your own, I'm looking at learning more about coturn
once I finished developing my application.
You can use simple-peer, a simple library for webrtc. Here is an example project with multiple users project, DEMO.

Mobile App chat server development

I have been tasked to develop a mobile chat app that will run both on Android and iPhone devices. I will be developing the respective clients in their native languages. Where I am a bit confused is in the development of the server.
My intended approach is to use 'long polling' to retrieve messages from the server and a separate connection to send messages to the server using GET/POST (obviously, there is no need for this to be long polled). My initial intention was to use Apache & PHP?MySQL for the server, but after a bit of reading, I learnt Apache won't be able to survive when there are lots of concurrent connections. I also learnt Node.js can survive where Apache failed by its capabilities to handle a lot of concurrent connections. Though, I don't have any knowledge about Node.js but if it will work, I am willing to do a crash course on it.
I know 'long polling' isn't the best method, but I can't seem to understand how XMPP can work for me on this project.
Thanks a lot in advance.
XMPP is the best way. You can install openfire on server side and for android you can use asmack. For Ios you can use xmpp lib.These are best combination. Communication with server is done through ssl connection.

Node.js and Socket.io - how far can they go with real time web applications?

I am going to build a web application to manage notes (think of something similar to Evernote). I have decided to use Backbone.js+JQuery client side.
Server-side, I haven't decided yet: either pure PHP (that I know very well) or Node.js+Socket.io (completely new to me).
I am considering Node.js+Socket.io because I would like to have my web application being real-time (i.e: if a user updates a note, that note gets updated instantly for a collaborator who shares that note, without reloading the page).
I was also considering, as a third alternative, to use Node.js and Socket.io for the UI and PHP for the REST API (I feel more comfortable to build an API with PHP). The PHP and Javascript code will share the MongoDB database.
My question is this: if I develop the REST API for my web application with PHP and a new note for the user gets created through the API (i.e.: the Android app sends an API request to create that note), will Node.js, Socket.it and Backbone.js be able to instantly update the UI of the user and show the new note on their screen? I think that can be called "push notification".
I hope I was clear enough.
Also, is there any alternative outstanding technology to build real time web applications?
Yes Node.js + Socket.IO will do a very good job of this. Node uses an event-loop, this means upon a request it is entered into a queue. Node deals with these requests one-by-one. Traditional web servers deal with a 'Thread-per-request' approach where a thread is created to handle that requests.
The benefit of Node here is that it doesn't need to context switch so often, this means it can deal with these requests very quickly... most likely faster than your PHP server. However Node runs as a single process, on a single CPU core. If your application is CPU intensive it could be that it blocks, meaning the time for each requests will be slower.
However it sounds to me like your application isn't CPU intensive, meaning Node.js will work well.
Decision
If your time is limited, and you don't want to learn a new skill (Node), PHP will be fine. If you have the time I recommend learning Node.js, as it is very strong when it comes to I/O intensive tasks such as a REST API for creating Notes.
Updating the UI
If your intended use is through a mobile device, I recommend using WebSockets but having a fallback such as long-polling. It is possible to update the Client UI using either Node or PHP. However from my experience it is much easier to do so using Socket.IO on Node.js.
Example Updating the client using Node.js / Socket.io
Client-side
socket.on('new-note', function (data) {
placeNewNote(data);
});
Server-side
socket.emit('new-note', data);
Getting Started With Node:
How do I get started with Node.js
Please also note, if you want to build a native Android mobile app which uses WebSockets... you will need to use: Java socket.io client
Using Node.js for both web server and push server is of course the best way. Especially since if you are going to use Node.js anyway then you have to learn it, so learning how to make a web server is only natural (I advice using the most famous Express framework).
Now you can use PHP for web server and Node.js for push server. To make them communicate with each other you would probably want to add Redis to your application. Redis will allow you to push notifications to any client connected to it, like PHP server or Node.js push server (and it scales well). From that point push server will push the data further to the client's browser.
Alternative technology would be for example Twisted server. Of course you'll need to learn Python in order to use it. And I don't know whether it supports WebSockets correctly. I think you should stick with Node.js + socket.io.

node.js, XMPP Strophe.js

I am currently thinking of adding a realtime notification system to my site and so far my choices are using node.js or an XMPP server with a js XMPP librairy such as strophe.js.
Right now i will just need it for a realtime notification systems on my site, but it will likely evole in more complexe features such as a chat system.
So i have the following questions:
How do these 2 technologies differs ?
Which of these 2 technologies would be "more suitable" to integrate in a site running on a LAMP environement.
Thanks,
If you want to use xmpp then you have 3 choices for the server technology to use:
Jabber2 (C++)
eJabberd (Erlang)
Openfire (Java)
Prosody IM (Lua)
so if you want to develop some unique server-side functionality you should have some skills in C++, erlang, java or lua. I use openfire because I'm familiar with java. Openfire also provide good plugin system. But if you just want to have some chat on your website then you can just setup one of these XMPP servers on your server-computer and the only thing you need after that is to code some browser-side functionality using strophe.js (which is pretty simple).
If you don't want to go with c++, ejabberd, java, lua and you still need some server-side functionality use node.js.
Both xmpp and node.js chat applications can be integrated with LAMP websites pretty easily (you only need to modify your website javascript, no php code needed), but if you prefer LAMP technology I bet node.js is the right thing for you.
XMPP is a protocol. The most common server implementations are ejabberd (Erlang) & Openfire (Java). Web clients connect over BOSH (long polling).
Node.js is simply an environment for javascript execution. Something like socket.io, is really more of a transport abstraction layer. It's up to you to design & implement your communication protocol.

Resources