Design and Implementation of a Custom Customer‑Service IM SDK
The article explains why a custom instant‑messaging SDK was built for a customer‑service web client, outlines its three‑layer architecture (WebSocket/gRPC network, RxJS‑driven data‑link, and application logic), and details reliability features such as ACKs, retries, deduplication, and ordering to improve performance, stability, and scalability.
The article describes the motivation for building a self‑developed instant‑messaging (IM) SDK for a customer‑service web client. The original third‑party SDK caused difficulties in debugging and high implementation costs, and could not meet the growing performance and experience requirements.
Key design considerations focus on eliminating perceived latency for agents when sending messages. This requires a reasonable sending strategy, minimizing heavy JavaScript execution, and ensuring smooth UI updates.
A high‑level architecture diagram is presented, showing three main layers: the Network layer (WebSocket + gRPC/protobuf), the Data‑Link layer (message pool, serialization, deserialization), and the Application layer (business logic).
To decouple framework code from business code, the publish‑subscribe pattern is implemented with RxJS. Core RxJS concepts—Observable, Observer, and Subscription—are introduced, and the message flow is illustrated with a diagram.
Network Layer : Handles TCP connections, message sending/receiving via WebSocket, and implements exponential backoff for reconnection and retry logic.
Data‑Link Layer : Defines message models, status enums, and a data pool for storing messages. It also covers protocol types (Hi, Login, Sub, Pub, etc.) and the creation of connections.
Application Layer : Shows how the SDK is instantiated on the business side, with optional filtering of special messages.
The reliability mechanisms include an ACK protocol, retry on timeout, deduplication using a globally unique msgId, and ordering based on sequence IDs generated by the IM gateway. Diagrams illustrate the ACK flow, retry logic, and ordering guarantees.
In summary, the self‑developed SDK improves stability, scalability, and performance for customer‑service IM by combining network engineering, RxJS‑based event handling, and robust message reliability strategies.
DeWu Technology
A platform for sharing and discussing tech knowledge, guiding you toward the cloud of technology.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.