毕业设计——基于springboot的在线聊天系统

本文详细介绍了使用SpringBoot、Netty、MUI、H5Plus、Nginx和FastDFS等技术搭建的在线聊天系统,涵盖了前端模块如登录注册、互信、通讯录等,以及后台的实时聊天功能实现和分布式文件系统的应用。

基于springboot的在线聊天系统设计与实现

本项目是一套聊天系统,包括前台手机界面及后台分布式系统,基于SpringBoot+Netty+MUI+H5Plus+Nginx+FastDFS分布式文件系统搭建的聊天系统。 前端聊天系统包含首页门户登录注册、互信、通讯录、发现、我等模块,添加了扫一扫,朋友圈等功能。 后台管理系统主要实现实时聊天功能。
说明

基于SpringBoot+Netty+MUI+H5Plus+Nginx+FastDFS分布式文件系统搭建的聊天系统,前端聊天系统包含首页门户登录注册、互信、通讯录、发现、我等模块,添加了扫一扫,朋友圈等功能。 后台通信系统主要实现实时聊天功能。

前言

项目致力于打造一个完整的聊天系统,采用现阶段流行技术实现。
项目介绍

项目是一套聊天系统,包括前台门户系统及后台通信系统,基于SpringBoot+Netty+MUI+H5Plus+Nginx+FastDFS实现。
前台聊天系统包含首页门户登录注册、互信、通讯录、发现、我等模块,添加了扫一扫,朋友圈等功能等模块。
后台通信系统主要实现实时聊天功能。
组织结构

huxin
├── huyan-huxin- – 前端聊天系统接口
├── huyan-huxin-mybatis – 基于后台数据层代码生成接口
├── huyan-huxin-netty – 后台聊天系统接口
└── huyan-huxin-hello – 基于聊天功能简单网络编程实现

技术选型
系统架构

在这里插入图片描述
业务架构

在这里插入图片描述
后端技术
技术 说明 官网
Spring Boot 容器+MVC框架 https://spring.io/projects/spring-boot
MyBatis ORM框架 http://www.mybatis.org/mybatis-3/zh/index.html
MyBatisGenerator 数据层代码生成 http://www.mybatis.org/generator/index.html
HikariCP 数据库连接池 https://github.com/brettwooldridge/HikariCP
FastDFS 对象存储 https://sourceforge.net/projects/fastdfs/
Nginx 反向代理服务器 http://nginx.org/
Netty 网络编程框架 https://netty.io/index.html
Maven 项目对象模型 http://maven.apache.org/
前端技术
技术 说明 官网
H5plus 用于调用手机端功能 http://www.html5plus.org/
MUI 原生手机端页面框架 http://dev.dcloud.net.cn/mui/
开发工具
工具 说明 官网
Eclipse 开发IDE https://www.eclipse.org/
X-shell Linux远程连接工具 http://www.netsarang.com/download/software.html
Navicat 数据库连接工具 http://www.formysql.com/xiazai.html
Xmind 思维导图设计工具 https://www.xmind.net/
开发环境
工具 版本号 下载
JDK 1.8 https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Mysql 5.7 https://www.mysql.com/
Nginx 1.10 http://nginx.org/en/download.html

部分java源码:

在这里插入代码片package com.huyan.netty;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.util.CharsetUtil;

/** 
  * @author 胡琰 
  * @version 创建时间:2019117日 下午12:37:40 
  * @Description:创建自定义助手类
  */
//SimpleChannelInboundHandler:对于请求来讲,相当于[入站,入境]
public class CustomHandler extends SimpleChannelInboundHandler<HttpObject> {
	
	@Override
	protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
		//获取channel
		Channel channel = ctx.channel();
		
		if (msg instanceof HttpRequest ) {
		
		//显示客户端的远程地址
		System.out.println(channel.remoteAddress());
		
		ByteBuf content = Unpooled.copiedBuffer("Hello netty~",CharsetUtil.UTF_8);
		
		//构建一个http response
		FullHttpResponse response = 
				new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,HttpResponseStatus.OK,content);
		response.headers().set(HttpHeaderNames.CONTENT_TYPE,"text/plain");
		response.headers().set(HttpHeaderNames.CONTENT_LENGTH,content.readableBytes());
		
		ctx.writeAndFlush(msg);
		
		}
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#channelActive(io.netty.channel.ChannelHandlerContext)
	 */
	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("channel...活跃");
		super.channelActive(ctx);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#channelInactive(io.netty.channel.ChannelHandlerContext)
	 */
	@Override
	public void channelInactive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("channel...不活跃");
		super.channelInactive(ctx);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#channelReadComplete(io.netty.channel.ChannelHandlerContext)
	 */
	@Override
	public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
		System.out.println("channelID读取完毕。。。");
		super.channelReadComplete(ctx);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#channelRegistered(io.netty.channel.ChannelHandlerContext)
	 */
	@Override
	public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
		System.out.println("channel...注册");
		super.channelRegistered(ctx);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#channelUnregistered(io.netty.channel.ChannelHandlerContext)
	 */
	@Override
	public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
		System.out.println("channel...移除");
		super.channelUnregistered(ctx);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#channelWritabilityChanged(io.netty.channel.ChannelHandlerContext)
	 */
	@Override
	public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
		System.out.println("channel可写可更改");
		super.channelWritabilityChanged(ctx);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#exceptionCaught(io.netty.channel.ChannelHandlerContext, java.lang.Throwable)
	 */
	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		System.out.println("捕获异常");
		super.exceptionCaught(ctx, cause);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#userEventTriggered(io.netty.channel.ChannelHandlerContext, java.lang.Object)
	 */
	@Override
	public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
		System.out.println("用户事件触发。。。");
		super.userEventTriggered(ctx, evt);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelHandlerAdapter#handlerAdded(io.netty.channel.ChannelHandlerContext)
	 */
	@Override
	public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
		System.out.println("助手类添加");
		super.handlerAdded(ctx);
	}

	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelHandlerAdapter#handlerRemoved(io.netty.channel.ChannelHandlerContext)
	 */
	@Override
	public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
		System.out.println("助手类移除");
		super.handlerRemoved(ctx);
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

毕业小助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值