Giter Club home page Giter Club logo

chatroom's Introduction

chatRoom

基于手写muduo网络库实现的集群聊天服务器和客户端代码,网络框架是经典的one thread one loop框架,并通过nginx实现tcp负载均衡、还通过redis消息订阅实现跨服务器聊天。

编译方式

cd build rm -rf * cmake .. make

运行

  1. 需要配置nginx负载均衡,启动nginx
  2. 启动reids服务
  3. 启动mysql,配置数据库和表
  4. 启动服务器:./ChatServer 127.0.0.1 6000/6002(负载均衡中配置6000和6002两个端口)
  5. 启动客户端:./ChatClient 127.0.0.1 80000(连接的是nginx服务器的端口,复杂算法会根据权重进行分配到对应的服务器中)

目前已完成工作

  1. muduo核心网络的编写, 采用one thread one loop模型**,主线程做侦听线程,用于侦听客户端连接,并将客户端连接通过轮询的方式分配给工作线程,每个线程中有一个EventLoop的事件循环,中间有epoll_wait监听发生事件的句柄,并执行相应的回调。
  2. 基于手写的网络库,实现了一个聊天服务器,并基于命令行,实现了一个简单的客户端,可以完成用户注册、登录、添加好友、创建群、添加群、单聊、群聊、注销功能。
  3. 通过nginx负载均衡,实现了实现了集群服务器,不同用户可以通过负载算法登录在不同的服务器中。
  4. 通过redis的订阅发布操作,实现了不同用户跨服务器聊天的问题
  5. 使用第三方的json库实现传输消息的序列化和反序列化

还未完成的工作(待完成)

  1. QT实现聊天室界面
  2. 将序列化和反序列化的方式改为websocket协议传输
  3. 添加文件传输功能(不同用户之间发生文件)

chatroom's People

Contributors

ha19991104 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.