前端连接阿里 API 网关 websocket 的 SDK【TypeScript 版】。
处理网关响应的各种信令,已集成重连机制,可自动重连,支持手动重连。
Usage
依赖@thallo/api-signature
yarn add @thallo/api-websocket @thallo/api-signature
import WebsocketApiClient from "@thallo/api-websocket";
import ApiSignature from "@thallo/api-signature";
const Signature = new ApiSignature({
appKey: "test",
appSecret: "test",
stage: "RELEASE",
});
const socket = new WebsocketApiClient({
host: "www.test.com",
appKey: "test",
Signature,
registerMethod: "POST",
registerPath: "/register",
logoutMethod: "POST",
logoutPath: "/logout",
});
socket.connect();
socket.onNotify = (message: string) => {
};
socket.logout();