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:
Lionel
2016-06-29 18:50:44 +02:00
committed by LionelB
parent a15f083327
commit eedc8069d2
2 changed files with 82 additions and 1 deletions
+60 -1
View File
@@ -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;
}
}