npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rcs-data

v0.1.7

Published

RCS消息数据结构

Downloads

5

Readme

总体说明

实现符合5G消息规范(RCS)的消息对象数据结构。

rcs

rcs-data只定义消息对象的数据结构,不执行数据处理相关的逻辑,例如:生成 ID。

消息结构

RcsMsg接口定义了消息对象的基本属性和方法。

RcsMsgBase类提供消息对象的最小实现。rcs-data中,所有消息对象记录的都是符合mime规范的内容,都包含 1 个mime/Entity实例。可以用header方法设置或读取消息头。因为,消息是可以嵌套的,消息的基本信息不一定用在自身一级,所以消息的基本信息没有记录在mine的头中。

消息对象可以分为携带消息内容的消息对象和用于补充信息其他消息的消息对象。携带消息内容的消息对象是RcsMsgMono类。携带其他消息的消息对象是RcsMsgDecorator,包括:递送报告请求(ImdnDemand),建议列表(SuggestionChiplist)和群发列表(RecipientList)。

一个完整的消息可能包含了多种消息对象,但是总有一个要发送的基础内容,RcsMsgInitail代表这类消息,包括:文本(Text),文件(File),卡片(Card/CardCarousel)和建议回复(SuggestionResponse)。

ImndReply代表递送报告回复。递送报告回复不会被“装饰”。

构造消息

rcs-data提供了用于构造消息对象的Builder类。构造消息对象前首先要生成Builder实例。

const builder = Builder(From)
  .conversationId(ConversationId)
  .contributionId(ContributionId)
  .messageId(MessageId)

通过builder实例创建具体的消息对象。

构造文本消息

const rcsmsg = builder.text(to, content)

构造文件消息

const rcsmsg = builder.file(to, fileInfo, thumbnailInfo)

构造卡片消息

const rcsmsg = builder.card(to, cardFrame)

解析消息

rcs-data支持解析两类格式的消息生成消息对象,包括:CPIM,JSON。

CPIM对应的是SIP消息中的body部分。

const rcsmsg = Parser.parseCPIM(sipBody)

JSON对应的是从非SIP通道收发的消息。

let rcsmsg = Parser.parseJSON(jsonObject)

消息对象通常是嵌套的,RcsMsg.contentType对应的是最外层消息对象的类型(通常是message/cpim),如果需要确定基本消息内容的类型,通过RcsMsg.initailContentType进行判断,类型的值在constants/Message_Content_Type中有枚举定义。

输出消息

发送消息对象时要输出符合发送通道要求格式的内容。

SIP 通道发送时,因为需要分别处理消息头和消息体,所以分别返回headerLinesbodyStringheaderLines加到 SIP 的消息头中,bodyString作为消息体。

let { headerLines, bodyString } = rcsmsg.output()

除了消息对象mime中携带的头信息,headerLines输出还会输出FromToConversation-IDContribution-ID头。请注意大小写。

非 SIP 通道发送时输出 JSON 格式的对象(没有序列化成字符串)。

let po = rcsmsg.outputPlainObject()

common

DateTime.value返回ISO8601带时区格式的日期时间字符串,例如:2022-01-29T10:37:30.350+08:00。

cpim

待补充

mime

待补充

单元测试

待补充