0


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

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

完整项目地址:https://download.csdn.net/download/lijunhcn/88430400

本项目是一套聊天系统,包括前台手机界面及后台分布式系统,基于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 创建时间:2019年1月17日 下午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);
    }
}

本文转载自: https://blog.csdn.net/lijunhcn/article/details/135311873
版权归原作者 辣椒种子 所有, 如有侵权,请联系我们删除。

“毕业设计——基于springboot的在线聊天系统设计与实现”的评论:

还没有评论