Implementing a live chat system in Website [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to add a live chat support channel in my website, mainly focused on new users who have specific questions about my services and i´be been thinking about the best way to implement this solution myself. do note that i do not intend to use third party solutions.
What i´ve thought about retrieving messages: i can have a form on the page that will activate on user click (like a "start chat" button), once the button is clicked, i will GET all messages in the database related to the client's IP address (if it's not a logged in user) through a web service and load it into the DOM. after this, i will have a javascript function that will execute every XX seconds asking whether there are new messages.
to send messages: the user will have a textArea with a "send" button that will trigger a POST to a web service in order to save their message into the database, on the Support/web admin side, everything will work in a similar fashion but with the option of having several chats at the same time. Also i think I can achieve this by using JQUERY and ajax requests.
Is this a good idea to implement a live chat services? or am I far off from the ideal way of doing this? I have browsed around and all i get is suggestions to use third party service which i definitely do not want to use. Thanks!

You should have a look at websockets, especially at the socket.io library, which provides you an event based communication between the clients and the server.
They even have an example how to create a live chat:
http://socket.io/get-started/chat/

I you want a chat that is not just a "proof of concept", you should go for using XMPP, it's the most popular (and maybe the only-one) opensource instant-messaging protocol. There are several implementations in multiple languages and it has proven its robustness.
Wikipedia :
Extensible Messaging and Presence Protocol (XMPP) is a communications protocol for message-oriented middleware based on XML (Extensible Markup Language). It enables the near-real-time exchange of structured yet extensible data between any two or more network entities.
source
You could also take a look at IRC, which is quite old but still useful.

Related

How to make a working login functions for my website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
Improve this question
I am just entered this game since last December. Now I finished HTML CSS and a little bit of Java Script yet I got stuck at this stage: I can do basic styling but I don't know how to make it interactive.
So my question is :
how can I make a login function for websites, which can gives visitor an account (sign up, login, forgot password) that can do basic things like comment , add to basket and favorite a product?
Don't need to be specific, please just highlight which language is involved in which stage.
Thanks ahead.
Now I finished HTML CSS and a little bit of Java Script
So your site is what is called a static website.
If you want to allow login and data storing, you need a dynamic website, that requires one of this technologies:
PHP
ASP (check also ASP.NET)
Node.js (with express or http module)
Django (Python's library)
A few others...
All this technologies are called server-side languages/technologies, and the most used for long years has been PHP, that now has some strong rivals in terms of usage.
You can use only html/js to create a website. But, if you need authentication, post comments, a server side is needed.
A js can call easely an API to authenticate (server side) and post comments with XHR. You have to create it. You need to know how Authentication headers works for server side. You need to have a database (sql, file or nosql, it's your choice) to save the users datas and rights.

Best practice about login [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have made a decent website using HTML, CSS and JavaScript. I'm new to programming.
Now I want to give some privacy to some users and create a login space. I saw that some people are using PHP, other JS or Node.js, but I haven't seen any good guide for the best practice.
I would like to make a robust website with up-to-date technologies. What is the best practice for this kind of request?
It is very wide question and have so many answers and techniques based on your requirements, for example if you need to implement it yourself you need to use token based authentication, AKA JSON Web Token, technique where you simply send a token to you client after validating their username/pass to be saved in the browser and later on you can send this token along with any further API/HTTP request(s) for validating your encoded token that was sent before by your authentication service.
Check JWT site to know more about different libraries that will help you implementing this technique in almost all known languages (PHP, NodejJ, Python, .NET, and Java) in just 10 minutes.
Backend server or used language should not be the issue as much as you should understand the technique itself.
If you want to use Amazon Cloud, you can totally depend on their authentication services they provide, its name is AWS Cognito
If you need to implement social based authentication, then you should use OAuth protocol for integration with different sites like Facebook/Twitter
If you're using JS for your website then I would suggest using Node.js for your database. What you'll be creating is an authentication front to your app to protect the data within. Here is a good link on getting started with authentication.
Check this out
You probably would like to take a look at PHP.
If you want good security for your database, you will want to take a look into hashing passwords so in case your database gets hacked, it's not so easy for a hacker to get everyone's information. Not only that, but you're not a safe site if you're not hashing user's passwords, you'd be a phishing site considering you'd be able to see their passwords. (DON'T DO THAT) Here
You will also want to learn SQL for handling the information that will needed to be saved to a database for access through queries. SQL

How to let people collaborate on same form with real time updates? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a html form with some fields that are linked to a database row that have to be modified at the same time by different users.
Every time one of the users edit an input field it may call a javascript onchange (or similar) function to update the specific column in the row, but the other users that have the same page opened don't see the change until they refresh the page.
What should I use to get it changed on all devices that are looking the page?
The backend is in PHP/MySQL.
Thank you
You have a way to send pushes to your backend server but now you need to get pulls from your server.
For this purpose, you need to maintain a constant communication channel between your client and server to get real time updates from your server. There are multiple options for this:
Websockets: A TCP websocket can be used for real time communication between server and client. See this thread to get more information about websocket support in PHP.
Polling (very dirty way): you can do frequent poll from your client to your server to see if there has been any updates or not. This way of implementation is really inefficient and not recommended at all but still, since some applications already have polls in their system, if your system is already doing frequent polls, you can attach the query to get form status with that poll.
There are a couple of possible approaches.
Have an ajax request in the client periodically poll the web server to retrieve the data. Though depending on how this is implemented, there could be some performance ramifications.
You could benefit from using WebSockets. Since you're using PHP and MySQL you might look into something like Ratchet. Depending on how far along the code base is you could potentially implement something with socket.io using node.
When you look for some already existing tools, this might something for you:
https://fusion-tables-api-samples.googlecode.com/svn/trunk/FusionTablesFormSync/docs/reference.html
When you do not find anything that matches your needs, you can write it on your own. Therefore you need Ajax (To transfer a change to the server), it is more easy to use in combination with jQuery.
http://www.w3schools.com/jquery/jquery_ajax_intro.asp
And you can also fetch the data from the server with ajax, but you have to do requests all the time, which is not very nice. An alternative would be websocket, but this need a lot of knowledge.

How does Facebook "like" button work? How to implement a plugin like it? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Say I have a Facebook-like website with a high volume of traffic. Now I want to implement something like a Facebook "Like" plugin(?) for my site that other websites can use on their site. Let's call it "Hooray". How do I exactly implement one?
Or how does Facebook, Pinterest, etc. generally do it?
To implement your "Hooray" button you need to have components mentioned below:
A web service which will consumed by the client SDK to report that someone has ""Hoorayed" the post etc.
You need to have a database where you can store who "hoorayed" what.
You can consider every entry as a post or say "Hurricane".
Now every post is unique so you can identify who "Hoorayed" what.
Create a web service which tells the user who "Hoorayed" what.
Create a client SDK. It could be a JS library for web applications or Objective C framework for iOS etc. These client libraries will consume web services which are mentioned above.
Just like FB you will have to ask the consumer of your "Hooray" service to register an app on your platform. You can generate an appid for them and then all the data can be tagged with that.
Obviously these are just pointers and you can create a much sophisticated workflow based on your needs.
If you go on the Facebook developers page, you can access the code for a Facebook "like" plugin in multiple languages and try to figure it out from there.

Best way to develop a group chat room [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm on developing a new application. It is going to work as follows,
=> All the user will be assigned to a group.
=> When a user logs in, the home page will show a textarea to add a message with all messages of the users who are in that group
=> Somtimes it is possible for one user will be assigned with more than one group, in that case the user have to select the groups they want to share their message.
=> The message sometimes have images and videos as well
In other words a chat room which is almost like the facebook newsfeed.
Now, my question, is there any plugins or script which is easy to be customised. Flash, Javascript.
Or what I can do is send ajax request every second to check the database for new message, grab and fetch on the screen. But the only thing I'm afraid is will it makes the server and/or the app slow or dead.
Please suggest me good solution dear genius brothers.
There are no such scripts to create an chatgroup that easy, you can use ajax to fetch the messages if you like.
But websockets or Server sent events would be a much better idea.
However using Server sent events (SSE) on apache is also not really a good idea as apache will create a proces for each open connection. If you would like to use SSE I suggest using nginx
Link to SSE.
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Error_handling
Websockets.
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
Well learn:
jquery
nodejs
And then come back with other questions.
If you can learn, then learn the following:
Node.js
Angular.js
Socket.io
Express.js
They can make your life easier and this app can be possible in minutes. Look for a demo on the angular site.

Categories