Giter VIP home page Giter VIP logo

cchat's Introduction

CChat

CChat是一个基于swoole扩展和swoole框架的在线聊天应用,采用H5的websocket于服务端通信。

1.安装

  1. php >= 5.4
  2. swoole-src >= 1.7.11

2.启动消息服务器

/path/to/php msg_server.php

3.启动代理服务器

/path/to/php proxy_server.php

4.架构设计

拓扑图

image

  1. 消息服务器:负责收发当前服务器的用户信息、接收代理服务器的信息,广播消息给该服务器的所有用户。
  2. 代理服务器:接收和分发消息服务器的信息。
  3. 配置服务器:存储配置信息(暂时还没把数据落地)。

5.前端交互

** 统一使用json格式

1.登录消息【主动】

{
	"cmd":"login",
	"uid":"用户的id",
	"name":"用户的名字",
	"rid":"房间的id"
}

2.发送消息【主动】

{
	"cmd":"message",
	"type":"消息类型:text/audio/pic",
	"msg":"要发送的内容",
	"rid":"房间的id",
	"tid":"私聊的用户id,【可选】" 
}

3.接收消息【被动】

{
	"cmd":"message",
	"uid":"用户的id",
	"name":"用户的名字",
	"type":"消息类型:text/audio/pic",
	"rid":"房间的id",
	"tid":"私聊的用户id,【可选】" ,
	"msg":"接收到的消息"
}

4.其他用户登录消息【被动】

{
	"cmd":"newUser",
	"uid":"用户的id",
	"name":"用户的名字",
	"rid":"房间的id"
}

5.错误信息【被动】

{
	"cmd":"error",
	"errCode":"错误码",
	"errMsg":"错误信息"
}

6.TODO

  1. 解决代理服务器,实现高可用
  2. 消息服务器负载均衡
  3. 数据落地

cchat's People

Contributors

iam2c avatar

Watchers

 avatar

Forkers

490011961 uiboom

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.