ITransport.d.ts 1.0 KB

1234567891011121314151617181920212223242526
  1. /** Specifies a specific HTTP transport type. */
  2. export declare enum HttpTransportType {
  3. /** Specifies no transport preference. */
  4. None = 0,
  5. /** Specifies the WebSockets transport. */
  6. WebSockets = 1,
  7. /** Specifies the Server-Sent Events transport. */
  8. ServerSentEvents = 2,
  9. /** Specifies the Long Polling transport. */
  10. LongPolling = 4
  11. }
  12. /** Specifies the transfer format for a connection. */
  13. export declare enum TransferFormat {
  14. /** Specifies that only text data will be transmitted over the connection. */
  15. Text = 1,
  16. /** Specifies that binary data will be transmitted over the connection. */
  17. Binary = 2
  18. }
  19. /** An abstraction over the behavior of transports. This is designed to support the framework and not intended for use by applications. */
  20. export interface ITransport {
  21. connect(url: string, transferFormat: TransferFormat): Promise<void>;
  22. send(data: any): Promise<void>;
  23. stop(): Promise<void>;
  24. onreceive: ((data: string | ArrayBuffer) => void) | null;
  25. onclose: ((error?: Error) => void) | null;
  26. }