UNPKG

4.43 kBTypeScriptView Raw
1import { IFrame } from './i-frame.js';
2import { IMessage } from './i-message.js';
3import { StompHeaders } from './stomp-headers.js';
4import { Versions } from './versions.js';
5/**
6 * This callback will receive a `string` as a parameter.
7 *
8 * Part of `@stomp/stompjs`.
9 */
10export declare type debugFnType = (msg: string) => void;
11/**
12 * This callback will receive a {@link IMessage} as parameter.
13 *
14 * Part of `@stomp/stompjs`.
15 */
16export declare type messageCallbackType = (message: IMessage) => void;
17/**
18 * This callback will receive a {@link IFrame} as parameter.
19 *
20 * Part of `@stomp/stompjs`.
21 */
22export declare type frameCallbackType = ((frame: IFrame) => void) | (() => void);
23/**
24 * This callback will receive a [CloseEvent]{@link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent}
25 * as parameter.
26 *
27 * Part of `@stomp/stompjs`.
28 */
29export declare type closeEventCallbackType<T = any> = (evt: T) => void;
30/**
31 * This callback will receive an [Event]{@link https://developer.mozilla.org/en-US/docs/Web/API/Event}
32 * as parameter.
33 *
34 * Part of `@stomp/stompjs`.
35 */
36export declare type wsErrorCallbackType<T = any> = (evt: T) => void;
37/**
38 * Parameters for [Client#publish]{@link Client#publish}.
39 * Aliased as publishParams as well.
40 *
41 * Part of `@stomp/stompjs`.
42 */
43export interface IPublishParams {
44 /**
45 * destination end point
46 */
47 destination: string;
48 /**
49 * headers (optional)
50 */
51 headers?: StompHeaders;
52 /**
53 * body (optional)
54 */
55 body?: string;
56 /**
57 * binary body (optional)
58 */
59 binaryBody?: Uint8Array;
60 /**
61 * By default, a `content-length` header will be added in the Frame to the broker.
62 * Set it to `true` for the header to be skipped.
63 */
64 skipContentLengthHeader?: boolean;
65}
66/**
67 * Backward compatibility, switch to {@link IPublishParams}.
68 */
69export declare type publishParams = IPublishParams;
70/**
71 * Used in {@link IRawFrameType}
72 *
73 * Part of `@stomp/stompjs`.
74 *
75 * @internal
76 */
77export declare type RawHeaderType = [string, string];
78/**
79 * The parser yield frames in this structure
80 *
81 * Part of `@stomp/stompjs`.
82 *
83 * @internal
84 */
85export interface IRawFrameType {
86 command: string | undefined;
87 headers: RawHeaderType[];
88 binaryBody: Uint8Array | undefined;
89}
90/**
91 * @internal
92 */
93export interface IStompSocketMessageEvent {
94 data?: string | ArrayBuffer;
95}
96/**
97 * Copied from Websocket interface to avoid dom typelib dependency.
98 *
99 * @internal
100 */
101export interface IStompSocket {
102 url: string;
103 onclose: ((ev?: any) => any) | undefined | null;
104 onerror: ((ev: any) => any) | undefined | null;
105 onmessage: ((ev: IStompSocketMessageEvent) => any) | undefined | null;
106 onopen: ((ev?: any) => any) | undefined | null;
107 terminate?: (() => any) | undefined | null;
108 /**
109 * Returns a string that indicates how binary data from the socket is exposed to scripts:
110 * We support only 'arraybuffer'.
111 */
112 binaryType?: string;
113 /**
114 * Returns the state of the socket connection. It can have the values of StompSocketState.
115 */
116 readonly readyState: number;
117 /**
118 * Closes the connection.
119 */
120 close(): void;
121 /**
122 * Transmits data using the connection. data can be a string or an ArrayBuffer.
123 */
124 send(data: string | ArrayBuffer): void;
125}
126/**
127 * Possible states for the IStompSocket
128 */
129export declare enum StompSocketState {
130 CONNECTING = 0,
131 OPEN = 1,
132 CLOSING = 2,
133 CLOSED = 3
134}
135/**
136 * Possible activation state
137 */
138export declare enum ActivationState {
139 ACTIVE = 0,
140 DEACTIVATING = 1,
141 INACTIVE = 2
142}
143/**
144 * @internal
145 */
146export interface IStomptHandlerConfig {
147 debug: debugFnType;
148 stompVersions: Versions;
149 connectHeaders: StompHeaders;
150 disconnectHeaders: StompHeaders;
151 heartbeatIncoming: number;
152 heartbeatOutgoing: number;
153 splitLargeFrames: boolean;
154 maxWebSocketChunkSize: number;
155 forceBinaryWSFrames: boolean;
156 logRawCommunication: boolean;
157 appendMissingNULLonIncoming: boolean;
158 discardWebsocketOnCommFailure: boolean;
159 onConnect: frameCallbackType;
160 onDisconnect: frameCallbackType;
161 onStompError: frameCallbackType;
162 onWebSocketClose: closeEventCallbackType;
163 onWebSocketError: wsErrorCallbackType;
164 onUnhandledMessage: messageCallbackType;
165 onUnhandledReceipt: frameCallbackType;
166 onUnhandledFrame: frameCallbackType;
167}
168
\No newline at end of file