J-IM recommended in this issue is a lightweight, high-performance IM developed with JAVA language, which supports hundreds of thousands to millions of online users in a single machine. The main goal is to reduce the threshold of instant messaging and quickly build a low-cost access online IM system.
class=”pgc-h-arrow-right” data-track=”2″>J-IM
J-IM is a lightweight, high-performance IM developed in JAVA language, which supports hundreds of thousands to millions of online users. The main goal is to reduce the threshold of instant messaging and quickly build a low-cost access online IM system. Through very simple message format can realize multi-end message sending between different protocols such as built-in (Http, Websocket, Tcp custom IM protocol), and provide through the http protocol api interface for message sending without caring what protocol the receiver belongs to, a message format to do everything!
class=”pgc-h-arrow-right” data-track=”4″>
- High performance (a single machine can support hundreds of thousands to millions of people online simultaneously)
- Lightweight and highly scalable
- Support cluster multi-machine deployment
- Support SSL/TLS encrypted transmission
- Message format extremely concise (JSON)
- One port supports plugging and unplugging multiple protocols (Socket custom IM protocol, Websocket, and Http), and each protocol can be deployed independently.
- Built-in message persistence (offline, history, roaming) to ensure message reliability and high-performance storage
- Various rich API interfaces.
- Zero-cost deployment, one-click startup.
class=”pgc-h-arrow-right” data-track=”15″>
< p data – track = “16” > < strong > 1. Chat request message structure < / strong > < / p >
{
"from": "Source ID",
"to": "Target ID",
"cmd":"Command code (11)int type ",
"createTime": "Message creation time type long ",
"msgType": "Message type int (0:text, 1:image, 2:voice, 3:vedio, 4:music, 5:news)",
"chatType":" Chat type int type (0: unknown,1: public chat,2: private chat)",
"groupId":"Group id is only required if chatType is (1),String type ",
"content": "content ",
"extras" : "Extended field,JSON object format: {' extended field name ':' extended field value'}"
}
Request :COMMAND_CHAT_REQ(11) Response :COMMAND_CHAT_RESP(12)
< p data – track = “19” > < strong > 2. The authentication request message structure < / strong > < / p >
{
"cmd":" Command code (3)int ",
"token": "
}
Request :COMMAND_AUTH_REQ(3) Response :COMMAND_AUTH_RESP(4)
< p data – track = “23” > < strong > 3. Handshake request message structure < / strong > < / p >
{
"cmd":" Command code (1)int ",
"hbyte":
}
Description: Request :COMMAND_HANDSHAKE_REQ(1) Response :COMMAND_HANDSHAKE_RESP(2)
< p data – track = “26” > < strong > 4. Login request message structure < / strong > < / p >
{
"cmd":"Command code (5)int type ",
"userId": "User account ",
"password": " ,
"token": " This field can coexist with userId, password, or only one)"
}
< p data – track = “28” > < strong > 5. Heart request message structure < / strong > < / p >
{
"cmd":" Command code (13)int type ",
"hbbyte":" Heartbeat 1 byte " Span
}
Request :COMMAND_HEARTBEAT_REQ(13) Response :COMMAND_HEARTBEAT_REQ(13)
8. Get persistent chat message (offline + history + roaming) request structure
{
< span class = "HLJS attr" - > "CMD" : < / span > < span class = "HLJS - string" > "command code (19) type int" < / span >,
"fromUserId":" message to send user id(this field must be used with userId to get both chat messages), optional ",
"userId":" Current user id(required field), when only this field,type must be 0, Get all the offline messages (friends + groups) of the current user.
"groupId":" group id(this field must be used with userId to get the current user-specified group chat message), optional ",
"beginTime":" start time of message interval Date milliseconds double type, optional ",
"endTime":" end time of message interval Date milliseconds double type, optional ",
"offset":" page offset int type, like 0 in Limit 0,10, optional ",
"count":" shows the number of messages, like 10 in Limit 0,10, optional ",
< span class = "HLJS - attr" > "type" : < / span > < span class = "HLJS - string" > "message type (0: offline messages, 1: history message)" < / span >
}
Request :COMMAND_GET_MESSAGE_REQ(19) Response :COMMAND_GET_MESSAGE_RESP(20)
使用
- server (quickly develop your own high-performance IM server) : Introduce jim-server and add the following code snippet to your pom.xml
<dependency>
<groupId>org.j-im</groupId>
<artifactId>jim-server</artifactId>
<version>3.0.0.v20200501-RELEASE</version>
</dependency>
- client (quickly develop your own IM client) : Introduce jim-client and add the following code snippet to your pom.xml
<dependency>
<groupId>org.j-im</groupId>
<artifactId>jim-client</artifactId>
<version>3.0.0.v20200501-RELEASE</version>
</dependency>
class=”pgc-h-arrow-right” data-track=”40″>