HubConnectionBuilder.d.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { HubConnection } from "./HubConnection";
  2. import { IHttpConnectionOptions } from "./IHttpConnectionOptions";
  3. import { IHubProtocol } from "./IHubProtocol";
  4. import { ILogger, LogLevel } from "./ILogger";
  5. import { IRetryPolicy } from "./IRetryPolicy";
  6. import { HttpTransportType } from "./ITransport";
  7. /** A builder for configuring {@link @microsoft/signalr.HubConnection} instances. */
  8. export declare class HubConnectionBuilder {
  9. /** Configures console logging for the {@link @microsoft/signalr.HubConnection}.
  10. *
  11. * @param {LogLevel} logLevel The minimum level of messages to log. Anything at this level, or a more severe level, will be logged.
  12. * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
  13. */
  14. configureLogging(logLevel: LogLevel): HubConnectionBuilder;
  15. /** Configures custom logging for the {@link @microsoft/signalr.HubConnection}.
  16. *
  17. * @param {ILogger} logger An object implementing the {@link @microsoft/signalr.ILogger} interface, which will be used to write all log messages.
  18. * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
  19. */
  20. configureLogging(logger: ILogger): HubConnectionBuilder;
  21. /** Configures custom logging for the {@link @microsoft/signalr.HubConnection}.
  22. *
  23. * @param {string} logLevel A string representing a LogLevel setting a minimum level of messages to log.
  24. * See {@link https://docs.microsoft.com/aspnet/core/signalr/configuration#configure-logging|the documentation for client logging configuration} for more details.
  25. */
  26. configureLogging(logLevel: string): HubConnectionBuilder;
  27. /** Configures custom logging for the {@link @microsoft/signalr.HubConnection}.
  28. *
  29. * @param {LogLevel | string | ILogger} logging A {@link @microsoft/signalr.LogLevel}, a string representing a LogLevel, or an object implementing the {@link @microsoft/signalr.ILogger} interface.
  30. * See {@link https://docs.microsoft.com/aspnet/core/signalr/configuration#configure-logging|the documentation for client logging configuration} for more details.
  31. * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
  32. */
  33. configureLogging(logging: LogLevel | string | ILogger): HubConnectionBuilder;
  34. /** Configures the {@link @microsoft/signalr.HubConnection} to use HTTP-based transports to connect to the specified URL.
  35. *
  36. * The transport will be selected automatically based on what the server and client support.
  37. *
  38. * @param {string} url The URL the connection will use.
  39. * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
  40. */
  41. withUrl(url: string): HubConnectionBuilder;
  42. /** Configures the {@link @microsoft/signalr.HubConnection} to use the specified HTTP-based transport to connect to the specified URL.
  43. *
  44. * @param {string} url The URL the connection will use.
  45. * @param {HttpTransportType} transportType The specific transport to use.
  46. * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
  47. */
  48. withUrl(url: string, transportType: HttpTransportType): HubConnectionBuilder;
  49. /** Configures the {@link @microsoft/signalr.HubConnection} to use HTTP-based transports to connect to the specified URL.
  50. *
  51. * @param {string} url The URL the connection will use.
  52. * @param {IHttpConnectionOptions} options An options object used to configure the connection.
  53. * @returns The {@link @microsoft/signalr.HubConnectionBuilder} instance, for chaining.
  54. */
  55. withUrl(url: string, options: IHttpConnectionOptions): HubConnectionBuilder;
  56. /** Configures the {@link @microsoft/signalr.HubConnection} to use the specified Hub Protocol.
  57. *
  58. * @param {IHubProtocol} protocol The {@link @microsoft/signalr.IHubProtocol} implementation to use.
  59. */
  60. withHubProtocol(protocol: IHubProtocol): HubConnectionBuilder;
  61. /** Configures the {@link @microsoft/signalr.HubConnection} to automatically attempt to reconnect if the connection is lost.
  62. * By default, the client will wait 0, 2, 10 and 30 seconds respectively before trying up to 4 reconnect attempts.
  63. */
  64. withAutomaticReconnect(): HubConnectionBuilder;
  65. /** Configures the {@link @microsoft/signalr.HubConnection} to automatically attempt to reconnect if the connection is lost.
  66. *
  67. * @param {number[]} retryDelays An array containing the delays in milliseconds before trying each reconnect attempt.
  68. * The length of the array represents how many failed reconnect attempts it takes before the client will stop attempting to reconnect.
  69. */
  70. withAutomaticReconnect(retryDelays: number[]): HubConnectionBuilder;
  71. /** Configures the {@link @microsoft/signalr.HubConnection} to automatically attempt to reconnect if the connection is lost.
  72. *
  73. * @param {IRetryPolicy} reconnectPolicy An {@link @microsoft/signalR.IRetryPolicy} that controls the timing and number of reconnect attempts.
  74. */
  75. withAutomaticReconnect(reconnectPolicy: IRetryPolicy): HubConnectionBuilder;
  76. /** Creates a {@link @microsoft/signalr.HubConnection} from the configuration options specified in this builder.
  77. *
  78. * @returns {HubConnection} The configured {@link @microsoft/signalr.HubConnection}.
  79. */
  80. build(): HubConnection;
  81. }