GithubHelp home page GithubHelp logo

my-backed's Introduction

我的

参考

  • packet => WsPacket, HttpPacket, TcpPackert
  • command,
  • message
  • responseBody
  • protocol

protocol 就是 http/websocket/tcp 等这些东西 packet 可以理解是,传输消息格式,如 json/msgpack 等 message 可以理解是消息实体

{
  "code": "111",
  "message": "info",
  "body": [],
  "version": 1
}
op: xx
version: 1
message:
  from: minbaby
  to: 'babab'
  type: chat/error/groupchat/headline/normal
  subject: title
  body: are you ok?
# req
iq:
  from: minbaby
  id: ???
  type: get
  query:fasdfdsa
# res
iq:
  from: minbaby
  id: ???
  type: result
  query:
    - item:
        jid: 1
        name: xxx
        group: friends
presence:
  from: minbaby
  to: abab
  type: unavailable
  status: gone home
{
  "id": "1",
  "delivery_data": "2",
  "deletion_date": "3",
  "text": "yes",
  "sender_id": "a",
  "group_id": "b",
  "recipient_id": "c",
  "records": "d"
}

heartbeat

{"op":7,"version":"v1"}

message

{"op":512,"version":"v1"}

C1: client1 C2: client2 S1: server1

C1 -> 发送消息, 问C2在线吗 -> S1 -> 看了以下,回复消息,C2在线 C1-> 发送消息给C2 -> S1 -> 看了一下C2在线 -> 给C2发送消息说 “C1 给你发了一条消息”


https://github.com/winlion/chat/blob/e6fe40db51/ctrl/chat.go

/**
消息发送结构体
1、MEDIA_TYPE_TEXT
{id:1,userid:2,dstid:3,cmd:10,media:1,content:"hello"}
2、MEDIA_TYPE_News
{id:1,userid:2,dstid:3,cmd:10,media:2,content:"标题",pic:"http://www.baidu.com/a/log,jpg",url:"http://www.a,com/dsturl","memo":"这是描述"}
3、MEDIA_TYPE_VOICE,amount单位秒
{id:1,userid:2,dstid:3,cmd:10,media:3,url:"http://www.a,com/dsturl.mp3",anount:40}
4、MEDIA_TYPE_IMG
{id:1,userid:2,dstid:3,cmd:10,media:4,url:"http://www.baidu.com/a/log,jpg"}
5、MEDIA_TYPE_REDPACKAGR //红包amount 单位分
{id:1,userid:2,dstid:3,cmd:10,media:5,url:"http://www.baidu.com/a/b/c/redpackageaddress?id=100000","amount":300,"memo":"恭喜发财"}
6、MEDIA_TYPE_EMOJ 6
{id:1,userid:2,dstid:3,cmd:10,media:6,"content":"cry"}
7、MEDIA_TYPE_Link 6
{id:1,userid:2,dstid:3,cmd:10,media:7,"url":"http://www.a,com/dsturl.html"}
7、MEDIA_TYPE_Link 6
{id:1,userid:2,dstid:3,cmd:10,media:7,"url":"http://www.a,com/dsturl.html"}
8、MEDIA_TYPE_VIDEO 8
{id:1,userid:2,dstid:3,cmd:10,media:8,pic:"http://www.baidu.com/a/log,jpg",url:"http://www.a,com/a.mp4"}
9、MEDIA_TYPE_CONTACT 9
{id:1,userid:2,dstid:3,cmd:10,media:9,"content":"10086","pic":"http://www.baidu.com/a/avatar,jpg","memo":"胡大力"}
*/

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.