UNPKG

1.35 kBPlain TextView Raw
1// Copyright (c) .NET Foundation. All rights reserved.
2// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
4// This will be treated as a bit flag in the future, so we keep it using power-of-two values.
5/** Specifies a specific HTTP transport type. */
6export enum HttpTransportType {
7 /** Specifies no transport preference. */
8 None = 0,
9 /** Specifies the WebSockets transport. */
10 WebSockets = 1,
11 /** Specifies the Server-Sent Events transport. */
12 ServerSentEvents = 2,
13 /** Specifies the Long Polling transport. */
14 LongPolling = 4,
15}
16
17/** Specifies the transfer format for a connection. */
18export enum TransferFormat {
19 /** Specifies that only text data will be transmitted over the connection. */
20 Text = 1,
21 /** Specifies that binary data will be transmitted over the connection. */
22 Binary = 2,
23}
24
25/** An abstraction over the behavior of transports. This is designed to support the framework and not intended for use by applications. */
26export interface ITransport {
27 connect(url: string, transferFormat: TransferFormat): Promise<void>;
28 send(data: any): Promise<void>;
29 stop(): Promise<void>;
30 onreceive: ((data: string | ArrayBuffer) => void) | null;
31 onclose: ((error?: Error) => void) | null;
32}
33
\No newline at end of file