Coder Social home page Coder Social logo

lloydzhou / redisim Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 330 KB

redis im server

License: MIT License

Python 4.14% Dockerfile 0.94% Makefile 0.78% C 76.37% HTML 0.24% JavaScript 9.24% Svelte 7.32% CSS 0.97%
redis im chat chat-application chatroom stream redis-module redis-modules

redisim's Introduction

使用redis stream实现im

redis key

  1. u:<uid> hash, 存放用户信息,例如name/avatar等
  2. s:<uid> stream, 这个队列用于接收/发送用户消息
  3. c:<uid> sorted set, 用于存放用户联系人(包括群组)
  4. gm:<gid> set, 用于存放群用户id
  5. gs:<gid> stream, 用于接收/发送群消息
  6. gi:<gid> hash, 存放群信息,例如name,还有一些配置信息(例如加群是否需要验证?)

redis module

redis module实现IM

IM.RECIVE

IM.RECIVE [uid] BLOCK [ms] COUNT [count] START [start]
获取历史消息,以及监听新的消息

IM.MESSAGE

IM.RECIVE [GROUP | USER] [uid | gid] [mid]
获取单条消息

IM.SEND

IM.SEND [uid] [tuid] [field value] [field value ... ]
发送单聊消息

IM.GSEND

IM.GSEND [uid] [gid] [field value] [field value ... ]
发送群聊消息

IM.USER

IM.USER [uid]
(get user info) 获取用户信息
IM.USER [uid] [field value] [field value ... ]
(create user or update user info)

IM.GROUP

IM.GROUP [gid]
(get group info)
IM.GROUP [gid] [uid] [field value] [field value ... ]
(create group or update group info)

IM.LINK

IM.LINK [uid] [tuid]
(add to user contact list)

IM.UNLINK

IM.UNLINK [uid] [tuid]
(remove from user contact list)

IM.JOIN

IM.LINK [uid] [gid]
(add to user group)

IM.QUIT

IM.QUIT [uid] [gid]
(remove from user group)

GUI

  1. using tornado WebSocketHandler to create websocket.
  2. using svelte create simple ui to send message (using localStorage to save message)

docker

docker run --rm --name=redisim -p 8888:8888 lloydzhou/redisim

redisim's People

Contributors

lloydzhou avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

redisim's Issues

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.