Click here to Skip to main content
14,022,607 members
Rate this:
 
Please Sign up or sign in to vote.
See more: , +
To keep it short and simple, I'd like to create a VERY SIMPLE chat application. This application would allow two users to connect to a server and chat in real time, or connect and send messages even when the other person is offline. I'm aiming for something similar to Discord, and I'm wondering if it's better to use JS/Electron to create a simple chat app that works both on web browsers and desktops, or if I should make a dedicated desktop application with Java / Python?

What I have tried:

As a fairly inexperienced develop who is currently in college it might prove as quite the challenge for me to use 3 languages at once as some people recommended, such as PHP, Ajax, and JS. Is there any way I could handle the server and the data processing and the client (UI design) with one single language, so that I can learn and expand on it?
Posted
Updated 12-Dec-18 2:35am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I will not try to compare any frameworks but would share my own experience with the frameworks. I did some research when I was trying to develop a chat app, and so the following are what I found.

Go with Node.js, and consider using Socket.io library. Socket.IO[^] is the library that allows you to utilize the power of web sockets and allows you to send push messages to the clients. This library is really light-weight.

I personally was developing an on-demand chat application using these two, and trust me, it is the easiest and simplest way to developed a chat application including, private rooms, group rooms, and allows you to control how many users are connected. Rest of the stuff is just your own business logic—I added MongoDB at the backend to persiste the chat messages and history. Passport, and other stuff can be added as well. But I leave that all to you.

For a quick demo, please check out their page, Socket.IO — Chat | Socket.IO[^], the server is merely,
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function(req, res){
  res.sendFile(__dirname + '/index.html');
});

io.on('connection', function(socket){
  console.log('a user connected');
});

http.listen(3000, function(){
  console.log('listening on *:3000');
});
And the web page, would be having,
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
  $(function () {
    var socket = io();
    $('form').submit(function(){
      socket.emit('chat message', $('#m').val());
      $('#m').val('');
      return false;
    });
  });
</script>
You can add your own controls and elements, but you get the point. Socket.io API and the references are also quick and easy to find, you will be in a good company. Socket.IO — Docs | Socket.IO[^]

Apart from this, I would have also suggested SignalR but .NET or C# was not in the tags, anyways you can check that too, Introduction to ASP.NET Core SignalR | Microsoft Docs[^]
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190417.4 | Last Updated 6 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100