Messaging Service Concept - Straas/Straas-web-document GitHub Wiki
Core Value
StraaS messaging service are dedicated to build a messaging sdk for live broadcasting, OTT, education and all kinds of applications needing a stable and scalable messaging platform to support hundreds of thousands concurrent user interacting in a single chat.
To fit in OTT scenarios, StraaS also provides management UI from our iframe sdk. Our management functions including delete inappropriate message
, blocked specific users
, add manager
...etc to help our customers could have better messaging experience.
In following sections, we will explain some design rationale through to help our clients have better understandings of our technology.
2 channel of messages
In StraaS messaging service, we define to types of messaging to fit to different applications. Theses 2 types are
text channel
data channel
The main differences of these 2 types are provided as following.
Text Channel
This kind of messages are limited by the input interval, user privilege and each user will have different kinds of privilege in input interval (e.g.: the managers are not limited by input interval). To manage the user text, most of the control, censorship and logic is designed for this channel.
Web, ios, Android)
Data Channel (This kind of messages are used to broadcast data and are not subjected to the input interval and user privilege.
And for data in data channel, there are 2 more different types of data to send, raw data and aggregated data:
raw data
: Raw data are used to broadcast json to users, e.g.: the current live shopping item for eCommerce. This kind of data could transports larger data size (2048 characters), and the available rps is smaller than others.aggregated data
: Aggregated data is designed for data which is highly correlated and could be compressed into a smaller size. This kind of data could have higher input rate, but the receiver could received constant frequency, by which the UI performance could be significantly improved. When using data channel, the sent key will be aggregated and the receiver method would receive the aggregated data in specific period, the receive data is a in json formate like: {"key": "like", "n": "20"}.
Summary
In summary, the properties are in following table.
text channel | data channel-raw data | data channel-aggregated data | |
---|---|---|---|
User Privilege | O | X | X |
Transporting Size | 120 | 2048 | 100 |
Input Rate | medium | low | high |
Received Rate | medium | low | constant |
Chat Metadata
Messaging service provides metadata API for you to store arbitrary data associated to a chat room. For example, you could store detail profile of the chat room owner. Metadata is stored in key and JSON value pairs, it could be retrieved through messaging SDK and server-side API.
There are 2 types of metadata, broadcasting and none-broadcasting: Any changes of broadcasting metadata will be synchronized to clients immediately through messaging SDK. None-broadcasting metadata needs to be query manually and accept lower change frequency, but it can carry much larger data.
In summary, the properties are in following table.
broadcast | none-broadcast | |
---|---|---|
Retrieving | Active server push | Manual query |
Transporting Size | 1024 | 4096 |
Change Rate | high | low |
Roles of Messaging Service
To provide different management privileges for different users, we offer role
to define the preset of privilege.
Following tables provide an overview of the role-privilege
mappings.
User Operations
promote NORMAL(member) to be MODERATOR | demote MODERATOR to be NORMAL(member)" | block NORMAL | revive blocked user | |
---|---|---|---|---|
LOCAL_MANAGER | O | O | O | O |
MODERATOR | X | X | O | O |
NORMAL(member) | X | X | X | X |
NORMAL(guest) | X | X | X | X |
BLOCKED | X | X | X | X |
Note that, only NORMAL user could be blocked/un-blocked |
Message Operations
chat in chatWriteMode:ALL | chat in chatWriteMode:LOGIN | chat in chatWriteMode: ANCHOR | remove message | flush all messages | skip interval | pin/unpin message | |
---|---|---|---|---|---|---|---|
LOCAL_MANAGER | O | O | O | O | O | O | O |
MODERATOR | O | O | O | O | O | O | O |
NORMAL(member) | O | O | X | X | X | X | X |
NORMAL(guest) | O | X | X | X | X | X | X |
BLOCKED | X | X | X | X | X | X | X |
Chat Operations
change chatWriteMode | |
---|---|
LOCAL_MANAGER | O |
MODERATOR | O |
NORMAL(member) | X |
NORMAL(guest) | X |
BLOCKED | X |
Chat Meta Operations
Set | |
---|---|
LOCAL_MANAGER | O |
MODERATOR | O |
NORMAL(member) | X |
NORMAL(guest) | X |
BLOCKED | X |
Banned Word Mechanism
By setting banned words in the chatroom, our service would blocked msg automatically. This is useful when there are not enough moderators in the chatroom to monitor.
Step
- When server gets an input msg, first it uses jieba library to segment the text.
- compare those segments with pre-defined banned words to check if there is exactly match
- server returns http code 422 when it detects banned words in msg
Refer to api section to utilize this functionality