In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The first to sixth articles of my series "fundamentals of High performance Server Development" cover some scattered and fragmented details of network programming. Today, in this article, I will introduce a self-developed instant messaging software flamingo (Chinese: flamingo) and open source its server and pc client code. In order to practice the theories mentioned in the previous articles.
A copy of the code has been uploaded on github and csdn.net:
Github address: https://github.com/baloonwj/flamingo
Csdn address:
Server side code address: http://download.csdn.net/detail/analogous_love/9805797
Pc client code: http://download.csdn.net/detail/analogous_love/9805795
The code on csdn may not be up to date, but the code on github is constantly maintained, including some new features and bug fixes. If you want to follow the latest features of flamingo, please follow the updates on github. If you only want to study the fundamentals and coding skills of network communication programs, the code on csdn will be sufficient.
At present, the instant messaging software implements the following functions (only the network-related functions are listed here, and the functions already implemented by other clients are not listed. Please find out for yourself):
Register
Log in
Find friends, find groups
Add friends, add groups
Friend list, group list, recent session
One-person chat function (including text, facial expressions, window jitter, offline files)
Group chat function (including sending text and facial expressions)
Modify the password
Modify personal information (custom nicknames, signatures, personal avatars, etc.)
Automatic upgrade function
Here are some screenshots:
The client also has many detailed functions, such as three display modes of avatars, online animation of friends, chat records, chat automatic reply function and so on. Students who are interested can explore and try it on their own, so there is no screenshot here.
The following describes the compilation and running environment of server code and pc client code:
The flamingo server-side code is compiled using cmake + makefile, developed using pure CentOS7.0 11, and runs on linux (my system is CentOS7.0). In order to support Craft 11, your gcc version should be at least 4.7, and my version is 4.8.5. In addition, using the mysql database, my database version is 5.7.17. I actually installed mariadb, an open source branch of mysql, as follows:
MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community and licensed by GPL. One of the reasons for developing this branch is that after Oracle acquired MySQL, there is a potential risk of shutting down MySQL, so the community uses a branching approach to avoid this risk. The goal of MariaDB is to be fully compatible with MySQL, including API and the command line, making it an easy replacement for MySQL.
Install mariadb, size 59m.
[root@yl-web yl] # yum install mariadb-server mariadb mariadb-devel
The relevant commands for the mariadb database are:
Systemctl start mariadb # launch MariaDB
Systemctl stop mariadb # stop MariaDB
Systemctl restart mariadb # restart MariaDB
Systemctl enable mariadb # set boot up
So start the database first.
[root@yl-web yl] # systemctl start mariadb
Then you can use mysql normally.
Copy the code
[root@yl-web yl] # mysql-u root-p
Enter password:
Welcome to the MariaDB monitor. Commands end with; or\ g.
Your MariaDB connection id is 3
Server version: 5.5.41-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
MariaDB [(none)] > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | performance_schema |
| | test |
+-+
4 rows in set (0.00 sec)
MariaDB [(none)] >
Copy the code
After installing mariadb, it also shows MariaDB [(none)] >, which may seem a little unaccustomed.
The server code is not only the server code of an instant messaging software, but also a general Craft 11 server framework.
How to use server code:
Compilation method:
Enter the program directory and enter cmake. (note that there is a period indicating the current directory)
There is no error, enter make
3. The result is two executable programs, mychatserver and myfilesever. Compilation completed
Deployment method:
Simple description: the user name of the mysql database is root, and the password is empty. Please set the corresponding user name and password according to your own needs (currently written in the program). Mychatserver is the chat server, myfileserver is the file server, the file server is responsible for uploading and downloading files sent in the chat, and myimgserver is responsible for uploading and downloading pictures in the chat. The three services are independent and independent of each other. Chat server listening port is 20000, file server port is 20001, picture server port number is 20002, these three ports are for client connection, where chat port and client are persistent connection, file port and picture can choose persistent connection or short connection.
When you run mychatserver for the first time, if you can successfully connect to mysql,mychatserver, you will automatically detect whether there is a database named myim, and create three new information tables, namely, t_user, t_user_relationship, and t_chatmsg. The first time you start the file server, the filecache directory is created, which is used to store chat pictures and offline files in the chat, as well as client upgrade packages.
To make it easier to view the code, I use Visual Studio to manage the code, and I can use VS to open the myserver.sln to view and manage the code. (the VS version must be VS2013 or above)
How to use the client code:
Compile:
1. Open the Flamingo.sln in the program directory with VS2013, you can use other versions of VS, but at least no less than VS2013, because the client code also uses a large number of Category 11 syntax and libraries, VS2013 and above can better support the syntax of Clover 11.
The open solution includes three projects: Flamingo is the main instant messaging program, CatchScreen is the screenshot tool used in chat, and iUpdateAuto is the decompression tool used in the upgrade function.
You can compile the whole solution with VS2013, and after successful compilation, the corresponding program will be generated in the Bin directory. Start Flamingo.exe to register an account and you can start using flamingo.
If you don't want to study the server code for the time being, but you want to use the client, you can connect to my test server. The address of the test server is:
Chat server address: 120.55.94.78 port number: 20000
File server address: 120.55.94.78 port number: 20001
Image server address: 120.55.94.78 Port number: 20002
You can set it in the network settings of the login screen (a button to the left of the minimization button in the upper right corner of the login screen).
That's all for this article. If you have any comments or suggestions on my program, or if you have any good ideas, please feel free to communicate with me or leave me a message (QQ:906106643). There is also some "borrowlism" in the code. in addition, the pictures and icons used in the program come from the network and are used for learning only, not for commercial purposes. If you accidentally infringe your copyright, please contact me.
In the next few articles, I will introduce in detail the framework and implementation details of the server-side and client-side code of this instant messaging software. Please wait for it.
Of course, I promise that I will continue to maintain flamingo to make this software better and better. Welcome to the update on github: https://github.com/baloonwj/flamingo. If you have any questions, you can leave a message on the blog or github question page (https://github.com/baloonwj/flamingo/issues). I will try my best to reply to you when I see it.
Welcome to join the group: 49114021 for technical discussion and exchange.
Welcome to the official account "easyserverdev". If you need my help with any technical or professional problems, you can contact me through this official account, which not only shares the experience and stories of high-performance server development, but also provides free technical answers and career answers for the majority of technical friends. If you have any questions, you can leave a message on the Wechat official account directly, and I will reply to you as soon as possible.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.