Author: small Fu Ge blog: bugstack. Cn video: mp.weixin.qq.com/s/OmXCY4fTf… Source: https://github.com/fuzhengwei/NaiveChat
❝
In this project, the author Xiao Fuge uses JavaFx, Netty4.x, SpringBoot, Mysql and other technology stacks and prefers DDD domain driver design to build a simulated desktop version of wechat chat project to achieve communication core functions. If this project can help you, please support (follow, like, share)!
❞
One, foreword
The fate of Netty started from version 5.0, when there was not much information on the Internet, with the study of sorting and writing a set of cases. But not long after I wrote the full set of cases, NEtty5.0, due to the performance problems of the latest version, was removed from the official website and netty4.0 was promoted. All right! In this way, many friends asked me if I could write a set of netty4.0 cases. Otherwise, it is really uncomfortable to write 4.0 code while watching 5.0 cases.
“Arrangement”! From 19 years began to write netty4.0 cases, from the basic, intermediate, advanced and source code analysis prepared a total of 37 chapters, basic can meet all small white on Netty entry. It’s a very popular topic on my blog right now. bugstack.cn
Later, more and more friends began to add me to wechat to discuss “Netty” learning. In the project under discussion, a variety of problems were encountered, although they were introduced in the case article, but the case is ultimately a guide to the beginning, not a complete practice. In time, I can understand bits and pieces of language, but it is still difficult to get started.
To do this! At the end of 19 years, 20 years of Spring Festival. Launched “Netty+JavaFX Actual Combat: Imitation desktop version oF wechat Chat Project”, and the full set of articles and code comb published to GitChat column, up to the release of the article sold a total of “716”, although not much. But fortunately, no one bought after the “spray” little Fuge! Also get a lot of small partners recognition! “Thank you here”
Throughout the project, only the op-ed part was paid for, and the source code was actually open source from the start. Only my fans less propaganda department to it!
So this time I wanted to strengthen my practice by deploying this open source IM code to the cloud to verify functionality. At the same time, in order to promote more, sincerely thank every share and like partners!
Good! So let’s start with services on the cloud.
There are too many cloud markets. Although I took advantage of my partner and asked for a month’s free cloud service from big factory, I was not allowed to advertise!
Second, open source code
“Open source” concern public number: BugStack wormhole stack, reply source download. You will get a list of download links, open the 15th “because I have a lot of open source”, give it a Star!
This IM code is divided into three groups of modules; UI, client, server. The reason for this split is to isolate THE UI presentation from the business logic, using events and interfaces to drive the code hierarchy cleaner and easier to extend and maintain.
The serial number | engineering | introduce |
---|---|---|
1 | itstack-naive-chat-ui | The UI side, developed using JavaFx, is provided in our UI side; Login box, chat box, and a large number of interactive interfaces, interfaces and events in the chat box. In the end, my UI side used Maven packaging to provide Jar packages to the outside world to separate the UI interface from the business behavior process. |
2 | itstack-naive-chat-client | Client is our communication core project, mainly using Netty4.x as our socket framework to complete communication interaction. In this project, I was responsible for introducing THE Jar package of UI, completing the events defined by UI (login verification, search to add friends, conversation notification, sending information, etc.), and using the communication protocol defined by us in the server side project to complete the information interaction. |
3 | itstack-navie-chat-server | The server side also uses Netty4.x as the socket communication framework, and uses Layui as the management background page in the server side, and our server side adopts the way of DDD domain driven design and Netty collection, in order to achieve our framework structure clean and easy to expand. |
4 | itstack.sql | System engineering database table structure and initialization data information, a total of 6 core tables; User table, group table, user group association table, friends table, chat table and chat record table. Users can expand and improve themselves in actual business development. At present, the structure of library table is only based on core functions. |
Iii. Function Overview
In this SET of IM, the server uses DDD domain-driven design mode to build. The function of Netty to SpringBoot for start and stop control, at the same time in the server to build a console can be very convenient operation of communication system, user and communication management. UI separation is adopted in the construction of the client to ensure the separation of business code and UI display, so that it is very easy to expand the control.
In addition, the function realization includes; Perfect imitation of wechat desktop client, login, search to add friends, user communication, group communication, emoticon sending and other core functions. If there is a function that needs to be used, it can be extended according to this system framework. The specific function points are as follows;
Iv. Project demonstration
❝
Landing page
❞
❝
The chat page
❞
❝
Add buddy
❞
❝
Message to remind
❞
Five, service on the cloud
1. Select the cloud provider
In fact, there are a lot of cloud market, even if you do not do any advertising will hit your mouth.
Including; Ali Cloud, Huawei cloud, Tencent cloud, Jingdong cloud, etc., according to their preferences. Here is a free trial of Huawei cloud presented by my partner, you can choose it on demand.
2. Configure the environment
“The installation package“
- jdk-8u231-linux-i586.tar.gz
- Apache tomcat – 8.5.37. Tar. Gz
“tool“
-
FTP tool
- Mac: FileZilla
- Win: Flxe Ftp
-
Linux Remote connection tool
- Mac: Just use your own
- Win: Xhell is very handy
“The command“
- Decompress: tar -zxvf
- Environment Variable Configuration
vi /etc/profile
#JDK global environment variable configuration
Export JAVA_HOME = / usr/local/Java/jdk1.8.0 _231
e.xport CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
Copy the code
- Find occupied port kill
fuser -v -n tcp 3389
kill -s 9 2157
Copy the code
- Mysql authorization
select user, host from mysql.user where user='root';
GRANT all PRIVILEGES ON database name.* TO'Database username'@'IP for authorized access' identified by 'Database user password';
flush privileges;
Copy the code
- Start and stop tomcat and view logs
./startup.sh
./shutdown.sh
tail -f catalina.out
Copy the code
3. Configure services
Service configuration, demonstrated in the top “video,” is about deploying server-side code to the cloud service. Here at the beginning mainly encountered some permissions and port access issues, overall or relatively smooth.
6. Project learning
“Learning links” : chat.itstack.org/ – Code “open source”, articles paid (volunteer support, make a friend)
- The opening words
- Chapter 1 – UI development
- 1.0: Column learning brief and full source code acquisition
- 1.1: split wechat page on PC and use JavaFx
- 1.2: Implementation of login box (structure definition, input box and login)
- 1.3: Enclosure login events and interfaces
- 1.4: Chat box body implementation one (overall structure definition, sidebar)
- 1.5: Implementation of chat box body ii (dialog bar)
- 1.6: Realizing three chat boxes (chat boxes)
- 1.7: Implementation of four chat box (friends bar)
- 1.8: Chat box implementation five (Friend fill box)
- 1.9: Chat box event definition
- 1.10: Exercise – chat emoji frame body implementation
- 1.11: Solution – chat emoticon frame implementation
- Chapter 2 – Architectural Design
- 2.1: Server architecture design
- 2.2: Definition of communication protocol package
- 2.3: Client architecture design
- 2.4: Database table structure design
- Chapter 3 – Function implementation
- 3.1: Realization of login function
- 3.2: Search and add friends
- 3.3: Dialog notification and reply
- 3.4: The user communicates with friends
- 3.5: Users communicate with groups
- 3.6: Disconnects and reconnects to recover communication
- 3.7: Server console setup
- 3.8: Exercise – chat expression sending function realization
- 3.9: Solution – chat expression sending function realization
Seven,
- The whole content mainly explains the actual combat project engineering
Netty+JavaFx: Imitation desktop wechat Chat
A framework architecture explanation, and deployment to the cloud server process. It is also for the convenience of you in the learning process, quickly start and then in-depth study. - Source code is open on demand to adapt to their own needs, this part of the source code also fusion
Small Fu Ge
Some development experience forSet up a good system structure
On, there will be a certain improvement. By paying attention to“The public no. :Bugstack wormhole stack
“To obtain. - I met a lot of friends on Twitter while writing technical articles, and they even
Continuously output technical articles
But there is basically no traffic. Sometimes a lot of good things still need to spread, share, let moreOriginal and quality content
, more in front of everyone. Like the man who wasn’t simple:Small Fu Ge
!
This article is formatted using MDNICE