UNPKG

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