毕业设计——基于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);
	}
}

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-15 10:42:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-15 10:42:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-15 10:42:01       82 阅读
  4. Python语言-面向对象

    2024-02-15 10:42:01       91 阅读

热门阅读

  1. Linux Chrome无法启动的原因(适用于Linux Edge)

    2024-02-15 10:42:01       57 阅读
  2. Shell脚本练习

    2024-02-15 10:42:01       56 阅读
  3. Electron实战之入门

    2024-02-15 10:42:01       45 阅读
  4. sqlserver2012 解决日志大的问题

    2024-02-15 10:42:01       52 阅读
  5. 寒假学习记录16:Express框架(Node)

    2024-02-15 10:42:01       59 阅读
  6. TypeScript快速入门

    2024-02-15 10:42:01       55 阅读
  7. MySQL定时备份及清理脚本(一劳永逸)-改良版本

    2024-02-15 10:42:01       54 阅读
  8. JVM指令手册

    2024-02-15 10:42:01       34 阅读