DEV Community

Cover image for Creating a realtime chat app with android , NodeJs and Socket.io

Creating a realtime chat app with android , NodeJs and Socket.io

Mohamed Aymen Ourabi on July 17, 2018

Introduction WebSockets are very beautiful tools that allows us to establish a realtime communication in modern web applications. In fac...
Collapse
 
sandeepkamboj12 profile image
Sandeep kamboj

What about when i send message and other device is offline.

You don't add this functionality.

Node.js is not reliable solution for chat applications. There is better options out there. Like XMPP server which is most trusted and reliable solutions.

Collapse
 
medaymentn profile image
Mohamed Aymen Ourabi

i didn't say that node js can do everything but at least the socket.io implementation is very simple and there are a lot of features that you can add.
i'v tried to establish a socket server once in java and it was like hell but with node js i'v totally love doing it coz it was just less than 20 line of code and everything works like a charm

Collapse
 
sandeepkamboj12 profile image
Sandeep kamboj

XMPP servers like OPENFIRE also totally built in java and provides much more functionality than node.js sockets.

Thread Thread
 
utkarshpro profile image
Utkarsh Srivastava

You can store messages in a database like redis and mark them unread and then serve them when the user logs back in. This is the approach I am using right now, let me know if something is wrong with this approach.

Thread Thread
 
imskshivam profile image
imskshivam

hey brother can you please help to make me understadable how do you work this such thing
im a student of 2nd year and i want to gain knowledeg

Collapse
 
imskshivam profile image
imskshivam

How will the socket.on listener work if the chat activity is not open ? I want the listener to run in the background all the time so whenever the new message is sent , it updates the Ui even if i am not using the app

Collapse
 
hoseincnn profile image
hosein-cnn

Hi
I wrote exactly the same code as you, but the ("a user connected") sentence is not displayed in cmd.
I have been involved in this issue for two months and there is nothing left on the stackoverflow and GitHub that I have not read.
I checked all the side works such as targetSandBoxVersion , clearTextTrafic , network_security_config , test https and http , open ports with telnet , test 10.0.2.2 and 127.0.0.1 urls , and etc .
Also My laptop does not have any server connection problem because I can send and receive http requests.
Could it be a problem with the android websocket firewall?
I'm really tired.
Please help me if anyone has a similar problem or knows the solution.

Collapse
 
quaspiel profile image
Quaspiel

Hey, I modified this a bit to create a Calibration App, so the App sends its coordinates to the Server whenever you touch the screen. It worked briefly, but it doesn't work anymore.

If someone could take I quick look over my code and tell me whats wrong with it, it would be greatly appreciated.

Heres a link to a Stackoverflow Post I created: stackoverflow.com/q/60074935/12845039

There you will find the code.

Collapse
 
mrhamadaseo profile image
MrHamada

welcome,
How to modify these applications and add to them the features of the paid version? For example the application found here لايت موشن مهكر

Collapse
 
lane_rose_85212da03ccf059 profile image
Lane Rose • Edited

Intriguing data yet it will be great to see on training. Will attempt to play out this code today. Likewise, it will be nice to make a cheating application to be utilized inside this visit. I talk about something like Snapchat spy applications portrayed here bestcellphonespyapps.com/best-cell... that are utilized to follow the movement of another client in Snapchat and different couriers.

Collapse
 
kenselgonzalez profile image
kenselgonzalez

Interesting information but it will be good to see on practice. Will try to perform this code today. Also, it will be good to make a cheating app to be used within this chat. I speak about something like Snapchat spy apps described here celltrackingapps.com/snapchat-chea... that are used to track the activity of another user in Snapchat and other messengers.

Collapse
 
hodor profile image
Kunal Rai

How will the socket.on listener work if the chat activity is not open ? I want the listener to run in the background all the time so whenever the new message is sent , it updates the Ui even if i am not using the app

Collapse
 
mohamedsalehev profile image
MohamedSalehEv

What is the difference between the library you use
'com.github.nkzawa:socket.io-client:0.5.0'
and between the official one from socketIO
io.socket:socket.io-client:1.0.0

Collapse
 
razushaikh profile image
razu-shaikh

Sir, How can I use my domain/hosting instead of localhost?
Thank you.

Collapse
 
bzazueta profile image
bzazueta

THANKS

Collapse
 
noobjoreth profile image
noobjoreth

Can you explain on thing more plz i want to make this in floating, can you share script for this,

Collapse
 
aparnak799 profile image
Aparna Krishnan

Your project was a total lifesaver during a hackathon! Hats off!