{"id":24901959,"url":"https://github.com/mxsm/im","last_synced_at":"2026-01-06T21:53:04.094Z","repository":{"id":105494483,"uuid":"148638099","full_name":"mxsm/IM","owner":"mxsm","description":"IM 基于Netty的即时通讯","archived":false,"fork":false,"pushed_at":"2022-12-20T07:07:07.000Z","size":484,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-02-01T21:41:20.287Z","etag":null,"topics":["im","netty","protobuf3"],"latest_commit_sha":null,"homepage":"https://blog.ljbmxsm.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mxsm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-13T12:59:27.000Z","updated_at":"2025-01-15T09:51:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"4c6b48dc-f75d-4e08-ba54-19fc0c7af406","html_url":"https://github.com/mxsm/IM","commit_stats":null,"previous_names":["mxsm/sim","mxsm/im"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxsm%2FIM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxsm%2FIM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxsm%2FIM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxsm%2FIM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mxsm","download_url":"https://codeload.github.com/mxsm/IM/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245904848,"owners_count":20691679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["im","netty","protobuf3"],"created_at":"2025-02-01T21:40:24.011Z","updated_at":"2026-01-06T21:53:04.046Z","avatar_url":"https://github.com/mxsm.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 即时通讯-IM\n![Deploy Status](https://travis-ci.com/mxsm/IM.svg?branch=develop)\n[![IM](https://codecov.io/gh/mxsm/IM/branch/develop/graph/badge.svg)](https://codecov.io/gh/mxsm/IM)\n[![Coverage Status](https://coveralls.io/repos/github/mxsm/IM/badge.svg?branch=develop)](https://coveralls.io/github/mxsm/IM?branch=develop)\n[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/mxsm/IM.svg)](http://isitmaintained.com/project/mxsm/IM \"Average time to resolve an issue\")\n[![Percentage of issues still open](http://isitmaintained.com/badge/open/mxsm/IM.svg)](http://isitmaintained.com/project/mxsm/IM \"Percentage of issues still open\")  \n\n### 模块\n\nIM 基于Netty的即时通讯\n![](https://github.com/mxsm/picture/blob/main/project/%E8%81%8A%E5%A4%A9%E5%B7%A5%E5%85%B7.png?raw=true)\n\n消息的转发模块叫鹊桥(取自中国航天探月工程的鹊桥中继卫星)\n\n### 线程模型\n\n![](https://github.com/mxsm/picture/blob/main/IM/%E6%9C%8D%E5%8A%A1%E7%AB%AF%E7%BA%BF%E7%A8%8B%E6%A8%A1%E5%9E%8B.png?raw=true)\n\n### 从源码构建\n\n```shell\ngit clone https://github.com/mxsm/IM.git\ncd IM\nmvn -Prelease-all -DskipTests clean install -U\ncd distribution/target/im-0.1-SNAPSHOT/im-0.1-SNAPSHOT\n```\n\n### 鹊桥(MagpieBridge)\n\n在鹊桥的集群中，只有一个Master,多个SLAVE。一个集群名称唯一，集群中的节点的名称可以相同。节点ID集群内必须唯一。\n\n- 节点ID最小的为MASTER，当Master掉线或者失去作用的时候回将节点ID最小的为MASTER。\n- 一个集群内节点名称必须相同。不同的节点名称可以不相同\n\n\n\n### 工程目录结构说明\n\n- **common**    包含了工程的通用工具类\n- **container**   包含了启动容器(当前只有spring容器的实现)\n- **core**   处理消息的逻辑\n- **distribute** 服务器分发消息(当前只有akka的实现)\n- **protocols**  IM的消息协议(当前用的protobuf)\n- **server**  IM通讯协议的服务(现在就实现了TCP)\n\n### 协议文件结构\n结构的设计参考了HTTP的方式\n```\nsyntax = \"proto3\";\n\npackage com.github.mxsm.protocol.protobuf;\n\noption java_package = \"com.github.mxsm.protocol.protobuf\";\noption java_outer_classname = \"Message\";\n\nmessage MessageProtobuf{\n\n\t Header header = 1;\n\t message Header{\n\t\t string protocol = 1; //协议\n\t\t string version = 2; //协议版本号\n\t\t string sender = 3; //消息发送者\n\t\t string receiver = 4; //消息接收者\n\t\t string messageType = 5; //消息类型\n\t\t string contentType = 6; //参照http content-type类型\n\t\t string terminalType = 7; //发送消息的终端\n\t\t string deviceToken = 8; //发送消息的终端设备号\n\t }\n\t Auth auth = 2;\n\t message Auth{\n\t\t string token = 1;\n\t }\n\t string messageUnique = 3; //消息唯一值\n\t int64 messageTime = 4; //消息的创建时间\n\t bytes payload = 5;//消息体\n}\n```\n\n\n### 编译protobuf.proto文件命令\n```\nprotoc -I=$SRC_DIR --java_out=$DST_DIR $SRC_DIR/addressbook.proto\n```\n\n### 消息类型\n\n及时通讯中消息类型大致在这里为两类  \n#### **1. 功能控制类型**\n主要用来控制与服务器之前的消息确认和服务器与客户端的连接关系\n\n```\nCONN //用户连接服务消息类型\nACK  //服务器收到消息和客户端收到消息的确认消息类型\nDISCONN // 断开与服务器的消息类型\n```\n\n#### **2. 数据传输类型**\n对于聊天来说就只是单聊和群聊\n```\nSINGLE  //单聊\nGROUP   //群聊\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxsm%2Fim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmxsm%2Fim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxsm%2Fim/lists"}