Giter Site home page Giter Site logo

gpslypy / chat_room Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sylar-yin/chat_room

0.0 0.0 0.0 8 KB

C++聊天室服务器,基于sylar框架开发,使用http服务器做资源服务,websocket server做聊天server

Home Page: http://www.sylar.top

CMake 9.98% HTML 12.74% C++ 74.49% Shell 1.29% Makefile 1.49%

chat_room's Introduction

编译执行

git clone https://github.com/sylar-yin/chat_room.git
cd chat_room
git submodule update --init --recursive
make
make -j
sh move.sh

bin/chat_room -s

设计思路

httpserver

支持文件访问,流量访问,index.html

实现一个文件的Servlet

1.handle 实现文件相关的操作。 2.ResourceSerlvet 实现文件访问

Websocket Server

  1. 普通的http实现,周期性轮训。
  2. websocket 长连接, 服务器可以主动推送数据,效率高

协议设计

协议格式: {type:"协议类型", data: {}}

1. login协议。 
    Client: {type: "login_request", "name": "昵称"}
    Server: {type: "login_response", result: 200, msg: "ok"}
    
2. send协议。
    Client:{type: "send_request", "msg" : "消息"}
    Server: {type: "send_response", result: 200, msg: "ok"}
    
3. user_enter 通知
    {type: "user_enter", msg: "xxx 加入聊天室", time:xxx}
    
4. user_leave 通知
    {type: "user_leave", msg: "xxx 离开聊天室", time:xxx}
    
5. msg 通知
    {type: "msg", msg: "具体聊天信息", user: "xxx", time: xxxx}

chat_room's People

Contributors

sylar-yin 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.