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

基于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);
	}
}
客服功能介绍 机器人智能聊天 客服手动在线离线 用户主动向客服发送信息(信息包括文本、表情包) 客服选择会话成员,并且主动向用户发送信息(信息包括文本、表情包) 用户/客服接收到对方发送的信息 客服主动关闭用户会话,离线列表显示离线用户,用户端提示客服主动关闭会话,本次会话结束 客服手动离线,清除所有会话列表,用户端提示客服已离线,本次会话结束 客服刷新或关闭页面下线,清除所有会话列表,用户端提示客服已离线,本次会话结束 用户刷新页面或关闭页面,客服端提示用户已下线,本次会话结束 客服切换右边工具栏,选择快捷回复,可选中快捷回复信息以此快速回复内容 发送信息,如果服务器中断,信息状态为 0(未发送出),若 20 秒服务器仍为断开,信息状态改成-1(发送失败),若 20 秒内服务器恢复,信息状态改成 1(发送成功) 在用户端加入 productId,用户可发送商品卡片 客服接收用户发送的商品卡片,并且查看详情 完成图片发送,若图片过大时进行图片压缩,图片超大时不允许发送 完成图片接收,查看 用户多台设备在线时,强制另一台设备下线 客服多台设备在线时,强制旧客服端下线,并且中断会员的会话 部分功能实现:https://blog.csdn.net/weixin_42000816/article/details/112131388 如果对您对此项目有兴趣,可以点 “Star” 支持一下 谢谢! 如果有任何的疑惑或建议,请在评论中提出,欢迎评论! 后端(service 文件)运行: npm install node app.js 前端(chatroom 文件)运行: npm install npm run serve
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

毕业小助手

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

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

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

打赏作者

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

抵扣说明:

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

余额充值