cbcore-ts
Version:
CBCore is a library to build web applications using pure Typescript.
66 lines (65 loc) • 3.02 kB
TypeScript
import { UIObject } from "../../uicore-ts";
import { CBSocketMessage, CBSocketMessageCompletionFunction, CBSocketMessageHandlerFunction, CBSocketMessageSendResponseFunction, CBSocketMultipleMessage, CBSocketMultipleMessagecompletionFunction } from "./CBDataInterfaces";
import { CBSocketClient } from "./CBSocketClient";
interface CBSocketCallbackHolderMessageDescriptor {
key: string;
message: {
identifier: string;
inResponseToIdentifier?: string;
keepWaitingForResponses?: boolean;
};
sentAtTime: number;
messageDataHash: string;
responseDataHash?: string;
mainResponseReceived: boolean;
anyMainResponseReceived: boolean;
completionPolicy: string;
completionFunction: CBSocketMessageCompletionFunction;
}
export declare class CBSocketCallbackHolder extends UIObject {
messageDescriptors: {
[x: string]: CBSocketCallbackHolderMessageDescriptor[];
};
handlers: {
[x: string]: CBSocketMessageHandlerFunction[];
};
onetimeHandlers: {
[x: string]: CBSocketMessageHandlerFunction[];
};
keysForIdentifiers: {
[x: string]: string;
};
isValid: boolean;
_storeableResponseKeys: string[];
_storedResponseHashesDictionary: {
[x: string]: {
hash: string;
validityDate: number;
};
};
_verifiedResponseHashesDictionary: {
[x: string]: boolean;
};
_socketClient: CBSocketClient;
constructor(socketClient: CBSocketClient, previousCallbackHolder?: CBSocketCallbackHolder);
triggerDisconnectHandlers(): void;
registerHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction): void;
registerOnetimeHandler(key: string, handlerFunction: CBSocketMessageHandlerFunction): void;
get storedResponseHashesDictionary(): {
[x: string]: {
hash: string;
validityDate: number;
};
};
storedResponseHashObjectForKey(requestKey: string, requestDataHash: string): any;
storedResponseForKey(requestKey: string, requestDataHash: string): any;
keyForRequestKeyAndRequestDataHash(requestKey: string, requestDataHash: string): string;
storeResponse(requestKey: string, requestDataHash: string, responseMessage: CBSocketMessage<any>, responseDataHash: string): void;
private saveStoredResponseHashesDictionary;
saveInLocalStorage(key: string, object: any): void;
socketShouldSendMessage(key: string, message: CBSocketMessage<any>, completionPolicy: string, completionFunction: CBSocketMessageCompletionFunction): boolean;
static defaultMultipleMessagecompletionFunction(responseMessages: any[], callcompletionFunctions: () => void): void;
socketWillSendMultipleMessage(messageToSend: CBSocketMultipleMessage, completionFunction?: CBSocketMultipleMessagecompletionFunction): void;
socketDidReceiveMessageForKey(key: string, message: CBSocketMessage<any>, sendResponseFunction: CBSocketMessageSendResponseFunction): void;
}
export {};