/webim

A web instant message(im) service written by Golang

Primary LanguageGoMIT LicenseMIT

webim

Build Status Go Report Card GoDoc

A web instant message(im) service written by Golang,this is the backend program.

Requisites

  • Golang
  • govendor
  • Mysql
  • Node
  • Docker
  • docker-compose

Quick start

git clone https://github.com/adolphlwq/webim $GOPATH/src/github.com/adolphlwq/webim
docker-compose up -d

Then browse localhost:8080

TODOs

  • auth(login and register)
    • login
    • register
    • list
  • contacts
    • list all contacts of you
      • list messafes unread
        • API
        • front end render
    • add new contact
    • delete contact
    • list contact
  • chat/message
    • into chat page when click a contact of contact list
    • unread set to zero
    • see history messages
    • send and receive message(real time if both are online)
    • delete messages
  • deploy
    • server
    • docker-compose
  • test case

Architecture design

chat logic design

  1. messages are saved to db(mysql)
  2. set state to each message
  3. three main situations when chat:
  • both are offline
  • both are online(use websocket)
  • one is online and the other offline(cache messages)

both online

        send message                  1. transfer msg to receiver by websocket
sender --------------> ChatServer -------------------------------------------> receiver 
        `msg_send`                 2. save msg to db with state `msg_done`

only one online

        send message                 1. save msg to db with state `msg_cache`
sender --------------> ChatServer -------------------------------------------> receiver (`offline`)
        `msg_send`                 

Reference