mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
add missing properties of $websocket instance
This PR add the missing properties of $websocket instance as mention in the documentation https://github.com/AngularClass/angular-websocket#properties
This commit is contained in:
+60
-1
@@ -30,6 +30,19 @@ declare namespace angular.websocket {
|
||||
autoApply?: boolean;
|
||||
}
|
||||
|
||||
/** Type corresponding to onMessage callbaks stored in $Websocket#onMessageCallbacks instance. */
|
||||
type IWebSocketMessageHandler = {
|
||||
fn: (evt: MessageEvent) => void;
|
||||
pattern: string | RegExp;
|
||||
autoApply: boolean;
|
||||
}
|
||||
|
||||
/** Type corresponding to items stored in $WebSocket#sendQueue instance. */
|
||||
type IWebSocketQueueItem = {
|
||||
message: any;
|
||||
defered: ng.IPromise<void>;
|
||||
}
|
||||
|
||||
interface IWebSocket {
|
||||
|
||||
/**
|
||||
@@ -81,6 +94,52 @@ declare namespace angular.websocket {
|
||||
*
|
||||
* @param data data to send, if this is an object, it will be stringified before sending
|
||||
*/
|
||||
send(data: string | {}): ng.IPromise<any>;
|
||||
send(data: string | {}): ng.IPromise<any>;
|
||||
|
||||
/**
|
||||
* WebSocket instance.
|
||||
*/
|
||||
socket: WebSocket;
|
||||
|
||||
/**
|
||||
* Queue of send calls to be made on socket when socket is able to receive data.
|
||||
*/
|
||||
sendQueue: IWebSocketQueueItem[];
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is opened.
|
||||
*/
|
||||
onOpenCallbacks: ((evt: Event) => void)[];
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when a message is received from the socket.
|
||||
*/
|
||||
onMessageCallbacks: IWebSocketMessageHandler[];
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when an error is received from the socket.
|
||||
*/
|
||||
onErrorCallbacks: ((evt: Event) => void)[];
|
||||
|
||||
/**
|
||||
* List of callbacks to be executed when the socket is closed.
|
||||
*/
|
||||
onCloseCallbacks: ((evt: CloseEvent) => void)[];
|
||||
|
||||
/**
|
||||
* Returns either the readyState value from the underlying WebSocket instance
|
||||
* or a proprietary value representing the internal state
|
||||
*/
|
||||
readyState: number;
|
||||
|
||||
/**
|
||||
* The initial timeout.
|
||||
*/
|
||||
initialTimeout: number;
|
||||
|
||||
/**
|
||||
* Maximun timeout used to determine reconnection delay.
|
||||
*/
|
||||
maxTimeout: number;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user