Merge branch 'release/2.2'

This commit is contained in:
Andrew Stanton-Nurse 2018-08-07 14:53:54 -07:00
commit 59fc98d516
25 changed files with 10454 additions and 115 deletions

View File

@ -502,7 +502,7 @@
"is-accessor-descriptor": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz",
"integrity": "sha1-FpwvbT3x+ZJhgHI2XJsOofaHhlY=",
"integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==",
"dev": true,
"requires": {
"kind-of": "^6.0.0"
@ -511,7 +511,7 @@
"is-data-descriptor": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz",
"integrity": "sha1-2Eh2Mh0Oet0DmQQGq7u9NrqSaMc=",
"integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==",
"dev": true,
"requires": {
"kind-of": "^6.0.0"
@ -520,7 +520,7 @@
"is-descriptor": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
"integrity": "sha1-OxWXRqZmBLBPjIFSS6NlxfFNhuw=",
"integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==",
"dev": true,
"requires": {
"is-accessor-descriptor": "^1.0.0",
@ -619,7 +619,7 @@
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dev": true,
"requires": {
"ms": "2.0.0"
@ -1684,14 +1684,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -1706,20 +1704,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@ -1836,8 +1831,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@ -1849,7 +1843,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -1864,7 +1857,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -1872,14 +1864,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@ -1898,7 +1888,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -1979,8 +1968,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@ -1992,7 +1980,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -2114,7 +2101,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -2597,8 +2583,7 @@
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=",
"dev": true
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4="
},
"is-data-descriptor": {
"version": "0.1.4",
@ -4619,7 +4604,7 @@
"bl": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz",
"integrity": "sha1-oWCRFxcQPAdBDO9j71Gzl8Alr5w=",
"integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==",
"dev": true,
"requires": {
"readable-stream": "^2.3.5",
@ -4649,6 +4634,16 @@
"dev": true,
"requires": {
"os-tmpdir": "~1.0.2"
},
"dependencies": {
"kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"requires": {
"is-buffer": "^1.1.5"
}
}
}
},
"to-array": {
@ -4660,7 +4655,7 @@
"to-buffer": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz",
"integrity": "sha1-STvUj2LXxD/N7TE6A9ytsuEhOoA=",
"integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==",
"dev": true
},
"to-object-path": {

View File

@ -2656,12 +2656,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -2676,17 +2678,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -2803,7 +2808,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -2815,6 +2821,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -2829,6 +2836,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -2836,12 +2844,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@ -2860,6 +2870,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -2940,7 +2951,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -2952,6 +2964,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -3073,6 +3086,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,6 @@
const path = require("path");
const baseConfig = require("../webpack.config.base");
module.exports = baseConfig(__dirname, "signalr-protocol-msgpack", {
externals: {
msgpack5: "msgpack5",

View File

@ -6,6 +6,7 @@
// it's a very new API right now.
// Not exported from index.
/** @private */
export class AbortController implements AbortSignal {
private isAborted: boolean = false;
public onabort: (() => void) | null = null;

View File

@ -10,7 +10,7 @@ export class HttpError extends Error {
/** The HTTP status code represented by this error. */
public statusCode: number;
/** Constructs a new instance of {@link HttpError}.
/** Constructs a new instance of {@link @aspnet/signalr.HttpError}.
*
* @param {string} errorMessage A descriptive error message.
* @param {number} statusCode The HTTP status code represented by this error.
@ -32,7 +32,7 @@ export class TimeoutError extends Error {
// tslint:disable-next-line:variable-name
private __proto__: Error;
/** Constructs a new instance of {@link TimeoutError}.
/** Constructs a new instance of {@link @aspnet/signalr.TimeoutError}.
*
* @param {string} errorMessage A descriptive error message.
*/

View File

@ -3,16 +3,19 @@
import { TextMessageFormat } from "./TextMessageFormat";
/** @private */
export interface HandshakeRequestMessage {
readonly protocol: string;
readonly version: number;
}
/** @private */
export interface HandshakeResponseMessage {
readonly error: string;
readonly minorVersion: number;
}
/** @private */
export class HandshakeProtocol {
// Handshake request is always JSON
public writeHandshakeRequest(handshakeRequest: HandshakeRequestMessage): string {

View File

@ -31,20 +31,20 @@ export interface HttpRequest {
/** Represents an HTTP response. */
export class HttpResponse {
/** Constructs a new instance of {@link HttpResponse} with the specified status code.
/** Constructs a new instance of {@link @aspnet/signalr.HttpResponse} with the specified status code.
*
* @param {number} statusCode The status code of the response.
*/
constructor(statusCode: number);
/** Constructs a new instance of {@link HttpResponse} with the specified status code and message.
/** Constructs a new instance of {@link @aspnet/signalr.HttpResponse} with the specified status code and message.
*
* @param {number} statusCode The status code of the response.
* @param {string} statusText The status message of the response.
*/
constructor(statusCode: number, statusText: string);
/** Constructs a new instance of {@link HttpResponse} with the specified status code, message and string content.
/** Constructs a new instance of {@link @aspnet/signalr.HttpResponse} with the specified status code, message and string content.
*
* @param {number} statusCode The status code of the response.
* @param {string} statusText The status message of the response.
@ -52,7 +52,7 @@ export class HttpResponse {
*/
constructor(statusCode: number, statusText: string, content: string);
/** Constructs a new instance of {@link HttpResponse} with the specified status code, message and binary content.
/** Constructs a new instance of {@link @aspnet/signalr.HttpResponse} with the specified status code, message and binary content.
*
* @param {number} statusCode The status code of the response.
* @param {string} statusText The status message of the response.
@ -71,18 +71,18 @@ export class HttpResponse {
* This class provides an abstraction over an HTTP client so that a different implementation can be provided on different platforms.
*/
export abstract class HttpClient {
/** Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public get(url: string): Promise<HttpResponse>;
/** Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP GET request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @param {HttpRequest} options Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public get(url: string, options: HttpRequest): Promise<HttpResponse>;
public get(url: string, options?: HttpRequest): Promise<HttpResponse> {
@ -93,18 +93,18 @@ export abstract class HttpClient {
});
}
/** Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public post(url: string): Promise<HttpResponse>;
/** Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP POST request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @param {HttpRequest} options Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public post(url: string, options: HttpRequest): Promise<HttpResponse>;
public post(url: string, options?: HttpRequest): Promise<HttpResponse> {
@ -115,18 +115,18 @@ export abstract class HttpClient {
});
}
/** Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public delete(url: string): Promise<HttpResponse>;
/** Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP DELETE request to the specified URL, returning a Promise that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {string} url The URL for the request.
* @param {HttpRequest} options Additional options to configure the request. The 'url' field in this object will be overridden by the url parameter.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link HttpResponse} describing the response, or rejects with an Error indicating a failure.
* @returns {Promise<HttpResponse>} A Promise that resolves with an {@link @aspnet/signalr.HttpResponse} describing the response, or rejects with an Error indicating a failure.
*/
public delete(url: string, options: HttpRequest): Promise<HttpResponse>;
public delete(url: string, options?: HttpRequest): Promise<HttpResponse> {
@ -137,19 +137,19 @@ export abstract class HttpClient {
});
}
/** Issues an HTTP request to the specified URL, returning a {@link Promise} that resolves with an {@link HttpResponse} representing the result.
/** Issues an HTTP request to the specified URL, returning a {@link Promise} that resolves with an {@link @aspnet/signalr.HttpResponse} representing the result.
*
* @param {HttpRequest} request An {@link HttpRequest} describing the request to send.
* @param {HttpRequest} request An {@link @aspnet/signalr.HttpRequest} describing the request to send.
* @returns {Promise<HttpResponse>} A Promise that resolves with an HttpResponse describing the response, or rejects with an Error indicating a failure.
*/
public abstract send(request: HttpRequest): Promise<HttpResponse>;
}
/** Default implementation of {@link HttpClient}. */
/** Default implementation of {@link @aspnet/signalr.HttpClient}. */
export class DefaultHttpClient extends HttpClient {
private readonly logger: ILogger;
/** Creates a new instance of the {@link DefaultHttpClient}, using the provided {@link ILogger} to log messages. */
/** Creates a new instance of the {@link @aspnet/signalr.DefaultHttpClient}, using the provided {@link @aspnet/signalr.ILogger} to log messages. */
public constructor(logger: ILogger) {
super();
this.logger = logger;

View File

@ -11,12 +11,14 @@ import { ServerSentEventsTransport } from "./ServerSentEventsTransport";
import { Arg, createLogger } from "./Utils";
import { WebSocketTransport } from "./WebSocketTransport";
/** @private */
const enum ConnectionState {
Connecting,
Connected,
Disconnected,
}
/** @private */
export interface INegotiateResponse {
connectionId?: string;
availableTransports?: IAvailableTransport[];
@ -24,6 +26,7 @@ export interface INegotiateResponse {
accessToken?: string;
}
/** @private */
export interface IAvailableTransport {
transport: keyof typeof HttpTransportType;
transferFormats: Array<keyof typeof TransferFormat>;
@ -31,6 +34,7 @@ export interface IAvailableTransport {
const MAX_REDIRECTS = 100;
/** @private */
export class HttpConnection implements IConnection {
private connectionState: ConnectionState;
private baseUrl: string;

View File

@ -283,11 +283,11 @@ export class HubConnection {
/** Removes the specified handler for the specified hub method.
*
* You must pass the exact same Function instance as was previously passed to {@link on}. Passing a different instance (even if the function
* You must pass the exact same Function instance as was previously passed to {@link @aspnet/signalr.HubConnection.on}. Passing a different instance (even if the function
* body is the same) will not remove the handler.
*
* @param {string} methodName The name of the method to remove handlers for.
* @param {Function} method The handler to remove. This must be the same Function instance as the one passed to {@link on}.
* @param {Function} method The handler to remove. This must be the same Function instance as the one passed to {@link @aspnet/signalr.HubConnection.on}.
*/
public off(methodName: string, method: (...args: any[]) => void): void;
public off(methodName: string, method?: (...args: any[]) => void): void {

View File

@ -11,7 +11,7 @@ import { JsonHubProtocol } from "./JsonHubProtocol";
import { NullLogger } from "./Loggers";
import { Arg, ConsoleLogger } from "./Utils";
/** A builder for configuring {@link HubConnection} instances. */
/** A builder for configuring {@link @aspnet/signalr.HubConnection} instances. */
export class HubConnectionBuilder {
/** @internal */
public protocol?: IHubProtocol;
@ -22,17 +22,17 @@ export class HubConnectionBuilder {
/** @internal */
public logger?: ILogger;
/** Configures console logging for the {@link HubConnection}.
/** Configures console logging for the {@link @aspnet/signalr.HubConnection}.
*
* @param {LogLevel} logLevel The minimum level of messages to log. Anything at this level, or a more severe level, will be logged.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public configureLogging(logLevel: LogLevel): HubConnectionBuilder;
/** Configures custom logging for the {@link HubConnection}.
/** Configures custom logging for the {@link @aspnet/signalr.HubConnection}.
*
* @param {ILogger} logger An object implementing the {@link ILogger} interface, which will be used to write all log messages.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @param {ILogger} logger An object implementing the {@link @aspnet/signalr.ILogger} interface, which will be used to write all log messages.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public configureLogging(logger: ILogger): HubConnectionBuilder;
public configureLogging(logging: LogLevel | ILogger): HubConnectionBuilder {
@ -47,28 +47,28 @@ export class HubConnectionBuilder {
return this;
}
/** Configures the {@link HubConnection} to use HTTP-based transports to connect to the specified URL.
/** Configures the {@link @aspnet/signalr.HubConnection} to use HTTP-based transports to connect to the specified URL.
*
* The transport will be selected automatically based on what the server and client support.
*
* @param {string} url The URL the connection will use.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public withUrl(url: string): HubConnectionBuilder;
/** Configures the {@link HubConnection} to use the specified HTTP-based transport to connect to the specified URL.
/** Configures the {@link @aspnet/signalr.HubConnection} to use the specified HTTP-based transport to connect to the specified URL.
*
* @param {string} url The URL the connection will use.
* @param {HttpTransportType} transportType The specific transport to use.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public withUrl(url: string, transportType: HttpTransportType): HubConnectionBuilder;
/** Configures the {@link HubConnection} to use HTTP-based transports to connect to the specified URL.
/** Configures the {@link @aspnet/signalr.HubConnection} to use HTTP-based transports to connect to the specified URL.
*
* @param {string} url The URL the connection will use.
* @param {IHttpConnectionOptions} options An options object used to configure the connection.
* @returns The {@link HubConnectionBuilder} instance, for chaining.
* @returns The {@link @aspnet/signalr.HubConnectionBuilder} instance, for chaining.
*/
public withUrl(url: string, options: IHttpConnectionOptions): HubConnectionBuilder;
public withUrl(url: string, transportTypeOrOptions?: IHttpConnectionOptions | HttpTransportType): HubConnectionBuilder {
@ -89,9 +89,9 @@ export class HubConnectionBuilder {
return this;
}
/** Configures the {@link HubConnection} to use the specified Hub Protocol.
/** Configures the {@link @aspnet/signalr.HubConnection} to use the specified Hub Protocol.
*
* @param {IHubProtocol} protocol The {@link IHubProtocol} implementation to use.
* @param {IHubProtocol} protocol The {@link @aspnet/signalr.IHubProtocol} implementation to use.
*/
public withHubProtocol(protocol: IHubProtocol): HubConnectionBuilder {
Arg.isRequired(protocol, "protocol");
@ -100,9 +100,9 @@ export class HubConnectionBuilder {
return this;
}
/** Creates a {@link HubConnection} from the configuration options specified in this builder.
/** Creates a {@link @aspnet/signalr.HubConnection} from the configuration options specified in this builder.
*
* @returns {HubConnection} The configured {@link HubConnection}.
* @returns {HubConnection} The configured {@link @aspnet/signalr.HubConnection}.
*/
public build(): HubConnection {
// If httpConnectionOptions has a logger, use it. Otherwise, override it with the one

View File

@ -3,6 +3,7 @@
import { TransferFormat } from "./ITransport";
/** @private */
export interface IConnection {
readonly features: any;

View File

@ -6,18 +6,18 @@ import { ILogger, LogLevel } from "./ILogger";
import { HttpTransportType, ITransport } from "./ITransport";
import { EventSourceConstructor, WebSocketConstructor } from "./Polyfills";
/** Options provided to the 'withUrl' method on {@link HubConnectionBuilder} to configure options for the HTTP-based transports. */
/** Options provided to the 'withUrl' method on {@link @aspnet/signalr.HubConnectionBuilder} to configure options for the HTTP-based transports. */
export interface IHttpConnectionOptions {
/** An {@link HttpClient} that will be used to make HTTP requests. */
/** An {@link @aspnet/signalr.HttpClient} that will be used to make HTTP requests. */
httpClient?: HttpClient;
/** An {@link HttpTransportType} value specifying the transport to use for the connection. */
/** An {@link @aspnet/signalr.HttpTransportType} value specifying the transport to use for the connection. */
transport?: HttpTransportType | ITransport;
/** Configures the logger used for logging.
*
* Provide an {@link ILogger} instance, and log messages will be logged via that instance. Alternatively, provide a value from
* the {@link LogLevel} enumeration and a default logger which logs to the Console will be configured to log messages of the specified
* Provide an {@link @aspnet/signalr.ILogger} instance, and log messages will be logged via that instance. Alternatively, provide a value from
* the {@link @aspnet/signalr.LogLevel} enumeration and a default logger which logs to the Console will be configured to log messages of the specified
* level (or higher).
*/
logger?: ILogger | LogLevel;
@ -36,7 +36,7 @@ export interface IHttpConnectionOptions {
/** A boolean indicating if negotiation should be skipped.
*
* Negotiation can only be skipped when the {@link transport} property is set to 'HttpTransportType.WebSockets'.
* Negotiation can only be skipped when the {@link @aspnet/signalr.IHttpConnectionOptions.transport} property is set to 'HttpTransportType.WebSockets'.
*/
skipNegotiation?: boolean;

View File

@ -6,19 +6,19 @@ import { TransferFormat } from "./ITransport";
/** Defines the type of a Hub Message. */
export enum MessageType {
/** Indicates the message is an Invocation message and implements the {@link InvocationMessage} interface. */
/** Indicates the message is an Invocation message and implements the {@link @aspnet/signalr.InvocationMessage} interface. */
Invocation = 1,
/** Indicates the message is a StreamItem message and implements the {@link StreamItemMessage} interface. */
/** Indicates the message is a StreamItem message and implements the {@link @aspnet/signalr.StreamItemMessage} interface. */
StreamItem = 2,
/** Indicates the message is a Completion message and implements the {@link CompletionMessage} interface. */
/** Indicates the message is a Completion message and implements the {@link @aspnet/signalr.CompletionMessage} interface. */
Completion = 3,
/** Indicates the message is a Stream Invocation message and implements the {@link StreamInvocationMessage} interface. */
/** Indicates the message is a Stream Invocation message and implements the {@link @aspnet/signalr.StreamInvocationMessage} interface. */
StreamInvocation = 4,
/** Indicates the message is a Cancel Invocation message and implements the {@link CancelInvocationMessage} interface. */
/** Indicates the message is a Cancel Invocation message and implements the {@link @aspnet/signalr.CancelInvocationMessage} interface. */
CancelInvocation = 5,
/** Indicates the message is a Ping message and implements the {@link PingMessage} interface. */
/** Indicates the message is a Ping message and implements the {@link @aspnet/signalr.PingMessage} interface. */
Ping = 6,
/** Indicates the message is a Close message and implements the {@link CloseMessage} interface. */
/** Indicates the message is a Close message and implements the {@link @aspnet/signalr.CloseMessage} interface. */
Close = 7,
}
@ -40,24 +40,25 @@ export type HubMessage =
/** Defines properties common to all Hub messages. */
export interface HubMessageBase {
/** A {@link MessageType} value indicating the type of this message. */
/** A {@link @aspnet/signalr.MessageType} value indicating the type of this message. */
readonly type: MessageType;
}
/** Defines properties common to all Hub messages relating to a specific invocation. */
export interface HubInvocationMessage extends HubMessageBase {
/** A {@link MessageHeaders} dictionary containing headers attached to the message. */
/** A {@link @aspnet/signalr.MessageHeaders} dictionary containing headers attached to the message. */
readonly headers?: MessageHeaders;
/** The ID of the invocation relating to this message.
*
* This is expected to be present for {@link StreamInvocationMessage} and {@link CompletionMessage}. It may
* be 'undefined' for an {@link InvocationMessage} if the sender does not expect a response.
* This is expected to be present for {@link @aspnet/signalr.StreamInvocationMessage} and {@link @aspnet/signalr.CompletionMessage}. It may
* be 'undefined' for an {@link @aspnet/signalr.InvocationMessage} if the sender does not expect a response.
*/
readonly invocationId?: string;
}
/** A hub message representing a non-streaming invocation. */
export interface InvocationMessage extends HubInvocationMessage {
/** @inheritDoc */
readonly type: MessageType.Invocation;
/** The target method name. */
readonly target: string;
@ -98,12 +99,12 @@ export interface CompletionMessage extends HubInvocationMessage {
readonly invocationId: string;
/** The error produced by the invocation, if any.
*
* Either {@link error} or {@link result} must be defined, but not both.
* Either {@link @aspnet/signalr.CompletionMessage.error} or {@link @aspnet/signalr.CompletionMessage.result} must be defined, but not both.
*/
readonly error?: string;
/** The result produced by the invocation, if any.
*
* Either {@link error} or {@link result} must be defined, but not both.
* Either {@link @aspnet/signalr.CompletionMessage.error} or {@link @aspnet/signalr.CompletionMessage.result} must be defined, but not both.
*/
readonly result?: any;
}
@ -116,7 +117,7 @@ export interface PingMessage extends HubMessageBase {
/** A hub message indicating that the sender is closing the connection.
*
* If {@link error} is defined, the sender is closing the connection due to an error.
* If {@link @aspnet/signalr.CloseMessage.error} is defined, the sender is closing the connection due to an error.
*/
export interface CloseMessage extends HubMessageBase {
/** @inheritDoc */
@ -142,21 +143,21 @@ export interface IHubProtocol {
readonly name: string;
/** The version of the protocol. */
readonly version: number;
/** The {@link TransferFormat} of the protocol. */
/** The {@link @aspnet/signalr.TransferFormat} of the protocol. */
readonly transferFormat: TransferFormat;
/** Creates an array of {@link HubMessage} objects from the specified serialized representation.
/** Creates an array of {@link @aspnet/signalr.HubMessage} objects from the specified serialized representation.
*
* If {@link transferFormat} is 'Text', the {@link input} parameter must be a string, otherwise it must be an ArrayBuffer.
* If {@link @aspnet/signalr.IHubProtocol.transferFormat} is 'Text', the `input` parameter must be a string, otherwise it must be an ArrayBuffer.
*
* @param {string | ArrayBuffer} input A string, or ArrayBuffer containing the serialized representation.
* @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
*/
parseMessages(input: string | ArrayBuffer, logger: ILogger): HubMessage[];
/** Writes the specified {@link HubMessage} to a string or ArrayBuffer and returns it.
/** Writes the specified {@link @aspnet/signalr.HubMessage} to a string or ArrayBuffer and returns it.
*
* If {@link transferFormat} is 'Text', the result of this method will be a string, otherwise it will be an ArrayBuffer.
* If {@link @aspnet/signalr.IHubProtocol.transferFormat} is 'Text', the result of this method will be a string, otherwise it will be an ArrayBuffer.
*
* @param {HubMessage} message The message to write.
* @returns {string | ArrayBuffer} A string or ArrayBuffer containing the serialized representation of the message.

View File

@ -19,7 +19,7 @@ export enum TransferFormat {
/** Specifies that only text data will be transmitted over the connection. */
Text = 1,
/** Specifies that binary data will be transmitted over the connection. */
Binary,
Binary = 2,
}
/** An abstraction over the behavior of transports. This is designed to support the framework and not intended for use by applications. */

View File

@ -20,7 +20,7 @@ export class JsonHubProtocol implements IHubProtocol {
/** @inheritDoc */
public readonly transferFormat: TransferFormat = TransferFormat.Text;
/** Creates an array of {@link HubMessage} objects from the specified serialized representation.
/** Creates an array of {@link @aspnet/signalr.HubMessage} objects from the specified serialized representation.
*
* @param {string} input A string containing the serialized representation.
* @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
@ -75,7 +75,7 @@ export class JsonHubProtocol implements IHubProtocol {
return hubMessages;
}
/** Writes the specified {@link HubMessage} to a string and returns it.
/** Writes the specified {@link @aspnet/signalr.HubMessage} to a string and returns it.
*
* @param {HubMessage} message The message to write.
* @returns {string} A string containing the serialized representation of the message.

View File

@ -5,7 +5,7 @@ import { ILogger, LogLevel } from "./ILogger";
/** A logger that does nothing when log messages are sent to it. */
export class NullLogger implements ILogger {
/** The singleton instance of the {@link NullLogger}. */
/** The singleton instance of the {@link @aspnet/signalr.NullLogger}. */
public static instance: ILogger = new NullLogger();
private constructor() {}

View File

@ -9,6 +9,7 @@ import { ITransport, TransferFormat } from "./ITransport";
import { Arg, getDataDetail, sendMessage } from "./Utils";
// Not exported from 'index', this type is internal.
/** @private */
export class LongPollingTransport implements ITransport {
private readonly httpClient: HttpClient;
private readonly accessTokenFactory: (() => string | Promise<string>) | undefined;

View File

@ -7,6 +7,7 @@ import { ITransport, TransferFormat } from "./ITransport";
import { EventSourceConstructor } from "./Polyfills";
import { Arg, getDataDetail, sendMessage } from "./Utils";
/** @private */
export class ServerSentEventsTransport implements ITransport {
private readonly httpClient: HttpClient;
private readonly accessTokenFactory: (() => string | Promise<string>) | undefined;

View File

@ -12,18 +12,18 @@
* @typeparam T The type of the items being sent by the server.
*/
export interface IStreamSubscriber<T> {
/** A boolean that will be set by the {@link IStreamResult} when the stream is closed. */
/** A boolean that will be set by the {@link @aspnet/signalr.IStreamResult} when the stream is closed. */
closed?: boolean;
/** Called by the framework when a new item is available. */
next(value: T): void;
/** Called by the framework when an error has occurred.
*
* After this method is called, no additional methods on the {@link IStreamSubscriber} will be called.
* After this method is called, no additional methods on the {@link @aspnet/signalr.IStreamSubscriber} will be called.
*/
error(err: any): void;
/** Called by the framework when the end of the stream is reached.
*
* After this method is called, no additional methods on the {@link IStreamSubscriber} will be called.
* After this method is called, no additional methods on the {@link @aspnet/signalr.IStreamSubscriber} will be called.
*/
complete(): void;
}
@ -33,20 +33,20 @@ export interface IStreamSubscriber<T> {
* @typeparam T The type of the items being sent by the server.
*/
export interface IStreamResult<T> {
/** Attaches a {@link IStreamSubscriber}, which will be invoked when new items are available from the stream.
/** Attaches a {@link @aspnet/signalr.IStreamSubscriber}, which will be invoked when new items are available from the stream.
*
* @param {IStreamSubscriber<T>} observer The subscriber to attach.
* @returns {ISubscription<T>} A subscription that can be disposed to terminate the stream and stop calling methods on the {@link IStreamSubscriber}.
* @returns {ISubscription<T>} A subscription that can be disposed to terminate the stream and stop calling methods on the {@link @aspnet/signalr.IStreamSubscriber}.
*/
subscribe(subscriber: IStreamSubscriber<T>): ISubscription<T>;
}
/** An interface that allows an {@link IStreamSubscriber} to be disconnected from a stream.
/** An interface that allows an {@link @aspnet/signalr.IStreamSubscriber} to be disconnected from a stream.
*
* @typeparam T The type of the items being sent by the server.
*/
// @ts-ignore: We can't remove this, it's a breaking change, but it's not used.
export interface ISubscription<T> {
/** Disconnects the {@link IStreamSubscriber} associated with this subscription from the stream. */
/** Disconnects the {@link @aspnet/signalr.IStreamSubscriber} associated with this subscription from the stream. */
dispose(): void;
}

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Not exported from index
/** @private */
export class TextMessageFormat {
public static RecordSeparatorCode = 0x1e;
public static RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);

View File

@ -6,6 +6,7 @@ import { ILogger, LogLevel } from "./ILogger";
import { NullLogger } from "./Loggers";
import { IStreamResult, IStreamSubscriber, ISubscription } from "./Stream";
/** @private */
export class Arg {
public static isRequired(val: any, name: string): void {
if (val === null || val === undefined) {
@ -21,6 +22,7 @@ export class Arg {
}
}
/** @private */
export function getDataDetail(data: any, includeContent: boolean): string {
let detail = "";
if (data instanceof ArrayBuffer) {
@ -37,6 +39,7 @@ export function getDataDetail(data: any, includeContent: boolean): string {
return detail;
}
/** @private */
export function formatArrayBuffer(data: ArrayBuffer): string {
const view = new Uint8Array(data);
@ -51,6 +54,7 @@ export function formatArrayBuffer(data: ArrayBuffer): string {
return str.substr(0, str.length - 1);
}
/** @private */
export async function sendMessage(logger: ILogger, transportName: string, httpClient: HttpClient, url: string, accessTokenFactory: (() => string | Promise<string>) | undefined, content: string | ArrayBuffer, logMessageContent: boolean): Promise<void> {
let headers;
if (accessTokenFactory) {
@ -72,6 +76,7 @@ export async function sendMessage(logger: ILogger, transportName: string, httpCl
logger.log(LogLevel.Trace, `(${transportName} transport) request complete. Response status: ${response.statusCode}.`);
}
/** @private */
export function createLogger(logger?: ILogger | LogLevel) {
if (logger === undefined) {
return new ConsoleLogger(LogLevel.Information);
@ -88,6 +93,7 @@ export function createLogger(logger?: ILogger | LogLevel) {
return new ConsoleLogger(logger as LogLevel);
}
/** @private */
export class Subject<T> implements IStreamResult<T> {
public observers: Array<IStreamSubscriber<T>>;
public cancelCallback: () => Promise<void>;
@ -125,6 +131,7 @@ export class Subject<T> implements IStreamResult<T> {
}
}
/** @private */
export class SubjectSubscription<T> implements ISubscription<T> {
private subject: Subject<T>;
private observer: IStreamSubscriber<T>;
@ -146,6 +153,7 @@ export class SubjectSubscription<T> implements ISubscription<T> {
}
}
/** @private */
export class ConsoleLogger implements ILogger {
private readonly minimumLogLevel: LogLevel;

View File

@ -6,6 +6,7 @@ import { ITransport, TransferFormat } from "./ITransport";
import { WebSocketConstructor } from "./Polyfills";
import { Arg, getDataDetail } from "./Utils";
/** @private */
export class WebSocketTransport implements ITransport {
private readonly logger: ILogger;
private readonly accessTokenFactory: (() => string | Promise<string>) | undefined;

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -35,4 +35,4 @@ namespace Microsoft.AspNetCore.SignalR.Tests
return new VerifyNoErrorsScope(loggerFactory, wrappedDisposable, expectedErrorsFilter);
}
}
}
}