2

开源IM项目OpenIM发布消息推送api,支持应用与IM互通深度融合

 2 years ago
source link: https://studygolang.com/articles/35585?fr=sidebar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

开源IM项目OpenIM发布消息推送api,支持应用与IM互通深度融合

OpenIM · 大约7小时之前 · 111 次点击 · 预计阅读时间 7 分钟 · 大约8小时之前 开始浏览    

以办公场景为例,比如员工入职通知,放假通知等业务通知,由oa系统处理具体的业务逻辑,再调用消息推送api,触达到目标用户。

以协同办公为例,员工收到系统推送的工作通知,有新任务需要处理。

640.png

员工点击工作通知,可以查看具体详情,每条通知有不同的发送者昵称和头像。这种通知类型是一种新的会话类型,全部聚合在同一个会话。

640-1.png

OpenIM简介 OpenIM:从服务端到客户端SDK开源即时通讯整体解决方案。开发者可以轻松替代第三方IM云服务,打造具备聊天、社交功能的app,也可以在自身应用中集成SDK,以提供即时通讯能力。开源IM的价值在于“一切皆可控”“我的信息我做主”,无论是技术,还是信息安全。

整体超过7.2K star,OpenIM作为开源IM的领跑者,持续添加新功能,包括消息推送api,群聊已读。服务端和sdk都是Apache-2.0 License授权协议,可以免费使用。带有UI的产品需要商业授权,有兴趣的客户可以联系我们深度交流。

5X8小时vip专属服务,包括:
(1)一对一技术咨询,微信 电话等各种方式;
(2)sdk使用辅导咨询;
(3)服务端架构及部署答疑;
(4)IM新需求优先排期;
(5)bug优先修复;
(6)系统维护和故障响应;
web端体验:https://open-im-online.rentsoft.cn/

安卓端体验:https://www.pgyer.com/OpenIM

iOS端体验:

https://testflight.apple.com/join/o956rTGx

640-2.png

单机性能及容量总结

服务器资源:8核16G内存, 6个机械磁盘,每个磁盘100G, mongo 分片,10MB带宽。

容量:用户同时在线10万以上,消息条数10亿。

性能评估:同时在线用户10万,每秒钟发送消息900条,(从发送者发出消息到接收到消息)消息延时1秒

可靠性总结

每条消息都能被对方精确收到,并成功落地app本地db。对于失败的3条消息,接收方确实没有收到,确保系统消息一致性。

系统具备优秀的平行扩展能力,除存储模块外,其他模块都无状态,支持亿级用户,千亿消息量。

github地址:https://github.com/OpenIMSDK/Open-IM-Server

开发者中心:https://doc.rentsoft.cn/#/

管理员通过后台接口发送通知类型消息

请求URL

http://x.x.x.x:10000/manager/send_msg

{ "operationID": "Oa notification operationID111", "sendID": "openIM123456", "recvID": "18712345678", "senderPlatformID": 2, "senderFaceURL": "http://www.head.com", "senderNickname": "系统通知2", "content": { "notificationName": "公文管理", "notificationFaceURL": "http://www.head1.com", "notificationType": 1, "text": "大家好,今天是...", "externalUrl":"", "mixType": 0, "pictureElem": { "sourcePath": "", "sourcePicture": { "uuid": "", "type": "", "size": 0, "width": 0, "height": 0, "url": "" }, "bigPicture": { "uuid": "", "type": "", "size": 0, "width": 0, "height": 0, "url": "" }, "snapshotPicture": { "uuid": "", "type": "", "size": 0, "width": 0, "height": 0, "url": "" } }, "soundElem": { "uuid": "", "soundPath": "", "sourceUrl": "", "dataSize": 0, "duration": 0 }, "videoElem": { "videoPath": "", "videoUUID": "", "videoUrl": "", "videoType": "", "videoSize": 0, "duration": 0, "snapshotPath": "", "snapshotUUID": "", "snapshotSize": 0, "snapshotUrl": "", "snapshotWidth": 0, "snapshotHeight": 0 }, "fileElem": { "filePath": "", "uuid": "", "sourceUrl": "", "fileName": "", "fileSize": 0 }, "ex": "" }, "contentType": 1400, "sessionType": 4, "isOnlineOnly": false, "offlinePushInfo": { "title": "admin revoke your message", "desc": "", "ex": "", "iOSPushSound": "default", "iOSBadgeCount": false } }Copy to clipboardErrorCopied 请求参数

参数名 类型 必选 说明 operationID string 是 操作ID,保持唯一,建议用当前时间微秒+随机数,用于后台链路追踪问题使用 sendID string 是 管理员ID,为后台config文件中配置的管理员ID中一个,默认openIM123456 recvID string 是 接收者userID senderPlatformID int 否 发送者平台号,模拟用户发送时填写, 1->IOS,2->Android,3->Windows,4->OSX,5->Web,5->MiniWeb,7->Linux senderFaceURL string 否 发送者头像,用于客户端通知会话产生 senderNickname string 否 发送者昵称,用于客户端通知会话产生 content object 是 消息的具体内容,内部是json 对象 notificationName string 是 通知标题 notificationFaceURL string 是 通知头像 notificationType int 是 通知类型,如:1代表入职通知,2代表离职通知 text string 是 通知正文e externalUrl string 否 通知点击后需要跳转到的地址链接(不填则无需跳转) mixType int 是 通知混合类型 0:纯文字通知 1:文字+图片通知 2:文字+视频通知 3:文字+文件通知 pictureElem object 否 图片元素对象 sourcePicture object 否 原图 bigPicture object 否 大图 snapshotPicture object 否 缩略图 soundElem object 否 声音元素对象 videoElem object 否 视频元素对象 fileElem object 否 文件元素对象 uuid string 否 对象唯一ID用于缓存使用 type/videoType/ string 否 图片类型/视频类型 size/dataSize/videoSize/snapshotSize/fileSize int 否 多媒体文件大小,单位字节 width/snapshotWidth int 否 图片/视频缩略图宽度 height/snapshotHeight int 否 图片/视频缩略图高度 url/sourceUrl/videoUrl string 否 图片/文件/视频的URL sourcePath/soundPath/videoPath/filePath string 否 文件路径,可不填写 fileName string 否 文件名字 ex string 否 扩展字段 contentType int 是 消息类型固定为1400 sessionType int 是 通知会话类型固定为4 isOnlineOnly bool 否 改字段设置为true时候,发送的消息服务器不会存储,接收者在线才会收到,不在线该消息丢失。 offlinePushInfo object 否 离线推送的具体内容,如果不填写,使用服务器默认推送标题 title string 否 推送的标题 desc string 否 推送的具体描述 ex string 否 扩展字段 iOSPushSound string 否 IOS的推送声音 iOSBadgeCount bool 否 IOS推送消息是否计入桌面图标未读数 返回示例

{ "errCode": 0, "errMsg": "", "data": { "serverMsgID": "", "clientMsgID": "", "sendTime": 1645697804432 } }Copy to clipboardErrorCopied 返回参数

参数名 类型 说明 errCode int 0成功,非0失败 errMsg string 错误信息 sendTime int 消息发送的具体时间,具体为毫秒的时间戳 serverMsgID string 服务器生成的消息的唯一ID clientMsgID string 客户端生成的消息唯一ID,默认情况使用这个为主键 消息类型格式描述

管理员消息发送字段中contentType支持的消息类型说明以及消息content的具体字段说明。

ContentType消息类型说明

ContentType值 类型说明 101 文本消息 102 图片消息 103 音频消息 104 视频消息 105 文件消息 106 群聊中的@类型消息 107 合并转发类型消息 108 名片消息 109 地理位置类型消息 110 自定义消息 111 撤回类型消息 112 已读回执类型消息 114 引用类型消息 Content具体内容

content内部为具体的json对象,不同的消息类型是不同的json对象

{ ..., "content": { "text": "nihao" }, .... }Copy to clipboardErrorCopied 参数名 必选 类型 说明 text 是 string 文本消息的具体内容 自定义消息

{ ..., "content": { "data": "", "description": "", "extension": "" }, .... }Copy to clipboardErrorCopied 参数名 类型 必选 说明 data json string 是 用户自定义的消息为json对象转换后的string description json string 否 扩展的描述信息为json对象转换后的string,可以不使用 extension json string 否 扩展字段,暂时不使用


有疑问加站长微信联系(非本文作者))

280

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:701969077


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK