开发者_运维技巧
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this questionI want to create a chatroom, but I am not entirely sure where to start.
I have programming experience in C and Java, and I am willing to learn. I would like to use either html5 or php, but this may not be correct.
If any one can point me to the right direction that would be great.
Thanks
You need to have a good understanding of server and client side technologies to make a full featured chat client. It's quite challenging, especially for a first time project. Some of the things you might need to use are:
- PHP for handling the communication between the browser and the server, taking the users input, parsing it and saving it.
- MySQL for storing chat records between users, keeping track of who has said what at which times.
- JavaScript and AJAX for enabling the clients browser to display latest chat records, polling the server for the latest chat records, sending a users chat records to the server.
It's not a trivial project, it took me years to learn these different languages enough to be able to create a secure and usable chat client. I would recommend something easier for a first time project.
There are many open source chat clients for PHP out there. AJAX chat is a good one as is PHPSimpleChat.
John, your question suggests you are right at the beginning of this process. Unfortunately the necessary answer is incredibly broad, but I'm going to do my best. I'll bullet point considerations you should make, roughly in order.
Identifying Useful (and prudent) shortcuts
- Can you get around needing to build a chatroom by using an existing chatroom service? I'm sure there are many services out there where you can take existing chatroom code and reuse it, or host your chatroom with someone else.
- If you do need to build it yourself, how much of your idea/requirements are truly unique? If there isn't too much of a difference, it's often best to customize someone else's code rather than building from scratch.
General Considerations in Designing your project
- How much time do you have? How much money? What quality level do you need?
Technologies to consider
LAMP is a very common web-development framework, which basically means Linux, Apache, MySQL (or equivalent), and PHP/Python/Perl/Ruby on Rails/Java. .NET is an alternative to this list. If the project is significant, I'd suggest taking a good look at the tradeoffs between these options and making a decision based on what feels right to you. PHP is the most common language, but Python and Rails (my favorite) are arguably more elegant. Any of these three options are completely solid and will put you in good shape, with strong online communities and plenty of support.
Getting Started
I was amazed by how rich the resources are online, and many free and high-quality. I got started in Rails by getting an intro book from Borders for a nice cohesive crash course, then I used SO, Railscasts, and other online resources to answer questions as I got them. Just remember to keep your questions specific and limited so future answers can be more concise and sharp than this one!
Best of luck with your project.
Google "node.js chat" for some info on how to construct one using just Javascript.
This one seems to be a popular example, but it looks like it's having some problems right now. Either way, you can view the source to get a better idea of what's going on.
PHP is probably the most relevant one you can use, as it controls your database and your server. This technically allows you to view the communication occurring with one another utilising the chatroom. Javascript can play a critical roles in the formalities rather than the technicalities, NODE.JS would be the most relevant in this situation. SQL instantly notates the inputs and stores them in particular encryptions, which would conveniently point out the user answer and format them in your database. In conclusion, PHP, Javascript, SQL, maybe a little Erlang, helping you in your runtime environment. Now, depending on your web server, Apache configuration would be required, depending on your status. While Perl and Ruby would play critical roles, try to refrain using them and learning their insights and notions first before utilising them due to their complexity. A Python route web server could come in handy for your chatroom, depending on your knowledge of course, and the general PHP code would maintain your port, maintaining control over the chat and therefore, making a good chat room.
精彩评论