Skip to content

PegasusWang/ChatRoom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ChatRoom web聊天室

基于tornado框架 + sqlite3 + redis

多聊天室,多人实时聊天

##开发环境 开发语言:     python
web服务器: tornado
数据库:         sqlite
缓存数据库:  redis
##Quick Start at local
###依赖组件:

  1. python 2.7+
  2. tornado
  3. redis server
  4. sqlite3

###Start
$ git clone git@github.com:suliangxd/ChatRoom.git
$ cd ChatRoom
$ cd src
$ redis-server (开启redis服务)
$ python init_sqlite.py(初始化数据库)
$ python server.py
then open your browser and type http://127.0.0.1:8000

##开发说明 ###功能结构图 version 1.0 fun ##实时聊天功能基本架构 version 1.0

当用户进入某个聊天室,即相当于订阅了此聊天室对应在redis里的一个channel
这里给出的架构图是指用户进入聊天室之后的实时聊天架构

思路说明:前端基于ajax的longpolling,后端采用redis的sub/pub机制
    1. 服务器端会阻塞请求直到有数据传递或超时才返回,这里设置超时时间为60s
    2. 客户端JavaScript响应处理函数会在处理完服务器返回的信息后,再次发出请求,重新建立连接
出现的问题:
    当客户端处理接收的数据、重新建立连接时,此时相当于取消订阅该房间的channel而服务器端可能有新的数据到达,
    这样的情况下可能会造成数据丢失     

架构图 V1.0
jiagou1.0

##Screenshots

###Login

![Login] (http://pic.sueri.cn/di-J5QC.jpg)
###chatroom

![ChatRoom] (http://pic.sueri.cn/di-O5Y6.png) ###chat

![Chat] (http://pic.sueri.cn/di-IGVR.jpg)

About

web聊天室 python tronado + sqlite3 + redis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 41.1%
  • JavaScript 28.6%
  • Python 25.1%
  • CSS 5.2%