UNPKG

2.33 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2017 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import { RepoInfo } from '../core/RepoInfo';
18export interface TransportConstructor {
19 new (connId: string, repoInfo: RepoInfo, applicationId?: string, appCheckToken?: string, authToken?: string, transportSessionId?: string, lastSessionId?: string): Transport;
20 isAvailable: () => boolean;
21 responsesRequiredToBeHealthy?: number;
22 healthyTimeout?: number;
23}
24export declare abstract class Transport {
25 /**
26 * Bytes received since connection started.
27 */
28 abstract bytesReceived: number;
29 /**
30 * Bytes sent since connection started.
31 */
32 abstract bytesSent: number;
33 /**
34 * An identifier for this connection, used for logging
35 */
36 abstract connId: string;
37 /**
38 * @param connId - An identifier for this connection, used for logging
39 * @param repoInfo - The info for the endpoint to send data to.
40 * @param transportSessionId - Optional transportSessionId if this is connecting to an existing transport session
41 * @param lastSessionId - Optional lastSessionId if there was a previous connection
42 * @interface
43 */
44 constructor(connId: string, repoInfo: RepoInfo, transportSessionId?: string, lastSessionId?: string);
45 /**
46 * @param onMessage - Callback when messages arrive
47 * @param onDisconnect - Callback with connection lost.
48 */
49 abstract open(onMessage: (a: {}) => void, onDisconnect: (a?: boolean) => void): void;
50 abstract start(): void;
51 abstract close(): void;
52 /**
53 * @param data - The JSON data to transmit
54 */
55 abstract send(data: {}): void;
56 abstract markConnectionHealthy(): void;
57 abstract markConnectionHealthy(): void;
58}