* Fix INodeSocket type * Fix compat * Remove unused import
This commit is contained in:
Родитель
14fb6b59fc
Коммит
f96195b129
|
@ -207,8 +207,7 @@ export async function makeApp(
|
|||
const adapter = services.mustMakeInstance<BotFrameworkHttpAdapter>('adapter');
|
||||
|
||||
try {
|
||||
// TODO: Fix INodeSocket type. Related issue https://github.com/microsoft/botbuilder-js/issues/4684.
|
||||
await adapter.process(req, socket as any, head, async (context) => {
|
||||
await adapter.process(req, socket, head, async (context) => {
|
||||
await bot.run(context);
|
||||
});
|
||||
} catch (err: any) {
|
||||
|
|
|
@ -194,8 +194,7 @@ export async function makeServer(
|
|||
const adapter = services.mustMakeInstance<BotFrameworkHttpAdapter>('adapter');
|
||||
|
||||
try {
|
||||
// TODO: Fix INodeSocket type. Related issue https://github.com/microsoft/botbuilder-js/issues/4684.
|
||||
await adapter.process(req, socket as any, head, async (context) => {
|
||||
await adapter.process(req, socket, head, async (context) => {
|
||||
await bot.run(context);
|
||||
});
|
||||
} catch (err: any) {
|
||||
|
|
|
@ -45,6 +45,7 @@ import { HttpClient } from '@azure/core-http';
|
|||
import { HttpOperationResponse } from '@azure/core-http';
|
||||
import { ICredentialProvider } from 'botframework-connector';
|
||||
import { INodeBuffer } from 'botframework-streaming';
|
||||
import { INodeDuplex } from 'botframework-streaming';
|
||||
import { INodeSocket } from 'botframework-streaming';
|
||||
import { InvokeResponse } from 'botbuilder-core';
|
||||
import { IReceiveRequest } from 'botframework-streaming';
|
||||
|
@ -187,6 +188,7 @@ export interface BotFrameworkAdapterSettings {
|
|||
export interface BotFrameworkHttpAdapter {
|
||||
process(req: Request_2, res: Response_2, logic: (context: TurnContext) => Promise<void>): Promise<void>;
|
||||
process(req: Request_2, socket: INodeSocket, head: INodeBuffer, logic: (context: TurnContext) => Promise<void>): Promise<void>;
|
||||
process(req: Request_2, socket: INodeDuplex, head: INodeBuffer, logic: (context: TurnContext) => Promise<void>): Promise<void>;
|
||||
}
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
|
@ -250,6 +252,7 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd
|
|||
connectNamedPipe(pipeName: string, logic: (context: TurnContext) => Promise<void>, appId: string, audience: string, callerId?: string, retryCount?: number): Promise<void>;
|
||||
process(req: Request_2, res: Response_2, logic: (context: TurnContext) => Promise<void>): Promise<void>;
|
||||
process(req: Request_2, socket: INodeSocket, head: INodeBuffer, logic: (context: TurnContext) => Promise<void>): Promise<void>;
|
||||
process(req: Request_2, socket: INodeDuplex, head: INodeBuffer, logic: (context: TurnContext) => Promise<void>): Promise<void>;
|
||||
processActivityDirect(authorization: string | AuthenticateRequestResult, activity: Activity, logic: (context: TurnContext) => Promise<void>): Promise<void>;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import type { INodeBuffer, INodeSocket } from 'botframework-streaming';
|
||||
import type { INodeBuffer, INodeDuplex, INodeSocket } from 'botframework-streaming';
|
||||
import type { Request, Response } from './interfaces';
|
||||
import type { TurnContext } from 'botbuilder-core';
|
||||
|
||||
|
@ -26,4 +26,15 @@ export interface BotFrameworkHttpAdapter {
|
|||
head: INodeBuffer,
|
||||
logic: (context: TurnContext) => Promise<void>
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
* Handle a web socket connection by applying a logic callback function to
|
||||
* each streaming request.
|
||||
*/
|
||||
process(
|
||||
req: Request,
|
||||
socket: INodeDuplex,
|
||||
head: INodeBuffer,
|
||||
logic: (context: TurnContext) => Promise<void>
|
||||
): Promise<void>;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import {
|
|||
import {
|
||||
INodeBuffer,
|
||||
INodeSocket,
|
||||
INodeDuplex,
|
||||
IReceiveRequest,
|
||||
IReceiveResponse,
|
||||
IStreamingTransportServer,
|
||||
|
@ -80,12 +81,29 @@ export class CloudAdapter extends CloudAdapterBase implements BotFrameworkHttpAd
|
|||
logic: (context: TurnContext) => Promise<void>
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
* Handle a web socket connection by applying a logic function to
|
||||
* each streaming request.
|
||||
*
|
||||
* @param req An incoming HTTP [Request](xref:botbuilder.Request)
|
||||
* @param socket The corresponding [INodeDuplex](xref:botframework-streaming.INodeDuplex)
|
||||
* @param head The corresponding [INodeBuffer](xref:botframework-streaming.INodeBuffer)
|
||||
* @param logic The logic function to apply
|
||||
* @returns a promise representing the asynchronous operation.
|
||||
*/
|
||||
async process(
|
||||
req: Request,
|
||||
socket: INodeDuplex,
|
||||
head: INodeBuffer,
|
||||
logic: (context: TurnContext) => Promise<void>
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async process(
|
||||
req: Request,
|
||||
resOrSocket: Response | INodeSocket,
|
||||
resOrSocket: Response | INodeSocket | INodeDuplex,
|
||||
logicOrHead: ((context: TurnContext) => Promise<void>) | INodeBuffer,
|
||||
maybeLogic?: (context: TurnContext) => Promise<void>
|
||||
): Promise<void> {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import { Duplex } from 'stream';
|
||||
import { DuplexOptions } from 'stream';
|
||||
import { Socket } from 'net';
|
||||
import { default as WebSocket_2 } from 'ws';
|
||||
|
||||
// @public
|
||||
|
@ -144,6 +145,14 @@ export interface INodeBuffer extends Uint8Array {
|
|||
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface INodeDuplex extends Duplex {
|
||||
// (undocumented)
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
// (undocumented)
|
||||
on(event: 'data', listener: (chunk: INodeBuffer) => void): this;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface INodeIncomingMessage {
|
||||
headers?: any;
|
||||
|
@ -151,218 +160,11 @@ export interface INodeIncomingMessage {
|
|||
}
|
||||
|
||||
// @public
|
||||
export interface INodeSocket {
|
||||
// (undocumented)
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<any>;
|
||||
// (undocumented)
|
||||
addListener(event: 'close', listener: () => void): this;
|
||||
// (undocumented)
|
||||
addListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
// (undocumented)
|
||||
addListener(event: 'end', listener: () => void): this;
|
||||
// (undocumented)
|
||||
addListener(event: 'readable', listener: () => void): this;
|
||||
// (undocumented)
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
// (undocumented)
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
// Warning: (ae-forgotten-export) The symbol "AddressInfo" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
address(): AddressInfo | string;
|
||||
// (undocumented)
|
||||
readonly bufferSize: number;
|
||||
// (undocumented)
|
||||
readonly bytesRead: number;
|
||||
// (undocumented)
|
||||
readonly bytesWritten: number;
|
||||
// (undocumented)
|
||||
connect(options: any, connectionListener?: () => void): any;
|
||||
// (undocumented)
|
||||
connect(port: number, host: string, connectionListener?: () => void): any;
|
||||
// (undocumented)
|
||||
connect(port: number, connectionListener?: () => void): any;
|
||||
// (undocumented)
|
||||
connect(path: string, connectionListener?: () => void): any;
|
||||
// (undocumented)
|
||||
connecting: boolean;
|
||||
// (undocumented)
|
||||
cork(): void;
|
||||
// (undocumented)
|
||||
destroy(error?: Error): void;
|
||||
// (undocumented)
|
||||
_destroy(error: Error | null, callback: (error: Error | null) => void): void;
|
||||
// (undocumented)
|
||||
destroyed: boolean;
|
||||
// (undocumented)
|
||||
emit(event: 'close'): boolean;
|
||||
// (undocumented)
|
||||
emit(event: 'data', chunk: any): boolean;
|
||||
// (undocumented)
|
||||
emit(event: 'end'): boolean;
|
||||
// (undocumented)
|
||||
emit(event: 'readable'): boolean;
|
||||
// (undocumented)
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
// (undocumented)
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
// (undocumented)
|
||||
end(cb?: () => void): void;
|
||||
// (undocumented)
|
||||
end(chunk: any, cb?: () => void): void;
|
||||
// (undocumented)
|
||||
end(chunk: any, encoding?: string, cb?: () => void): void;
|
||||
// (undocumented)
|
||||
eventNames(): Array<string | symbol>;
|
||||
// (undocumented)
|
||||
_final(callback: (error?: Error | null) => void): void;
|
||||
// (undocumented)
|
||||
getMaxListeners(): number;
|
||||
// (undocumented)
|
||||
isPaused(): boolean;
|
||||
// (undocumented)
|
||||
listenerCount(type: string | symbol): number;
|
||||
// (undocumented)
|
||||
listeners(event: string | symbol): Function[];
|
||||
// (undocumented)
|
||||
readonly localAddress: string;
|
||||
// (undocumented)
|
||||
readonly localPort: number;
|
||||
// (undocumented)
|
||||
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
export interface INodeSocket extends Socket {
|
||||
// (undocumented)
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
// (undocumented)
|
||||
on(event: 'close', listener: (had_error: boolean) => void): this;
|
||||
// (undocumented)
|
||||
on(event: 'connect', listener: () => void): this;
|
||||
// (undocumented)
|
||||
on(event: 'data', listener: (data: INodeBuffer) => void): this;
|
||||
// (undocumented)
|
||||
on(event: 'end', listener: () => void): this;
|
||||
// (undocumented)
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
// (undocumented)
|
||||
once(event: 'close', listener: () => void): this;
|
||||
// (undocumented)
|
||||
once(event: 'data', listener: (chunk: any) => void): this;
|
||||
// (undocumented)
|
||||
once(event: 'end', listener: () => void): this;
|
||||
// (undocumented)
|
||||
once(event: 'readable', listener: () => void): this;
|
||||
// (undocumented)
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
// (undocumented)
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
// (undocumented)
|
||||
pause(): this;
|
||||
// Warning: (ae-forgotten-export) The symbol "WritableStream_2" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
pipe<T extends WritableStream_2>(destination: T, options?: {
|
||||
end?: boolean;
|
||||
}): T;
|
||||
// (undocumented)
|
||||
prependListener(event: 'close', listener: () => void): this;
|
||||
// (undocumented)
|
||||
prependListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
// (undocumented)
|
||||
prependListener(event: 'end', listener: () => void): this;
|
||||
// (undocumented)
|
||||
prependListener(event: 'readable', listener: () => void): this;
|
||||
// (undocumented)
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
// (undocumented)
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
// (undocumented)
|
||||
prependOnceListener(event: 'close', listener: () => void): this;
|
||||
// (undocumented)
|
||||
prependOnceListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
// (undocumented)
|
||||
prependOnceListener(event: 'end', listener: () => void): this;
|
||||
// (undocumented)
|
||||
prependOnceListener(event: 'readable', listener: () => void): this;
|
||||
// (undocumented)
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
// (undocumented)
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
// (undocumented)
|
||||
push(chunk: any, encoding?: string): boolean;
|
||||
// (undocumented)
|
||||
rawListeners(event: string | symbol): Function[];
|
||||
// (undocumented)
|
||||
read(size?: number): any;
|
||||
// (undocumented)
|
||||
_read(size: number): void;
|
||||
// (undocumented)
|
||||
readable: boolean;
|
||||
// (undocumented)
|
||||
readonly readableFlowing: boolean | null;
|
||||
// (undocumented)
|
||||
readonly readableHighWaterMark: number;
|
||||
// (undocumented)
|
||||
readonly readableLength: number;
|
||||
// (undocumented)
|
||||
ref(): any;
|
||||
// (undocumented)
|
||||
removeAllListeners(event?: string | symbol): this;
|
||||
// (undocumented)
|
||||
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
// (undocumented)
|
||||
resume(): this;
|
||||
// (undocumented)
|
||||
setDefaultEncoding(encoding: string): this;
|
||||
// (undocumented)
|
||||
setEncoding(encoding: string): this;
|
||||
// (undocumented)
|
||||
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
||||
// (undocumented)
|
||||
setMaxListeners(n: number): this;
|
||||
// (undocumented)
|
||||
setNoDelay(noDelay?: boolean): this;
|
||||
// (undocumented)
|
||||
setTimeout(timeout: number, callback?: () => void): this;
|
||||
// (undocumented)
|
||||
uncork(): void;
|
||||
// (undocumented)
|
||||
unpipe(destination?: any): this;
|
||||
// (undocumented)
|
||||
unref(): any;
|
||||
// (undocumented)
|
||||
unshift(chunk: any): void;
|
||||
// (undocumented)
|
||||
wrap(oldStream: any): this;
|
||||
// (undocumented)
|
||||
writable: boolean;
|
||||
// (undocumented)
|
||||
readonly writableHighWaterMark: number;
|
||||
// (undocumented)
|
||||
readonly writableLength: number;
|
||||
// Warning: (ae-forgotten-export) The symbol "ValidBuffer" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
write(buffer: ValidBuffer, cb?: (err?: Error) => void): boolean;
|
||||
// (undocumented)
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
// (undocumented)
|
||||
write(buffer: ValidBuffer): boolean;
|
||||
// (undocumented)
|
||||
write(str: string, cb?: Function): boolean;
|
||||
// (undocumented)
|
||||
write(str: string, encoding?: string, fd?: string): boolean;
|
||||
// (undocumented)
|
||||
write(data: any, encoding?: string, callback?: Function): void;
|
||||
// (undocumented)
|
||||
write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;
|
||||
// (undocumented)
|
||||
write(chunk: any, encoding?: string, cb?: (error: Error | null | undefined) => void): boolean;
|
||||
// (undocumented)
|
||||
_write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
|
||||
// (undocumented)
|
||||
_writev?(chunks: Array<{
|
||||
chunk: any;
|
||||
encoding: string;
|
||||
}>, callback: (error?: Error | null) => void): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
|
|
@ -12,6 +12,7 @@ export {
|
|||
INodeBuffer,
|
||||
INodeIncomingMessage,
|
||||
INodeSocket,
|
||||
INodeDuplex,
|
||||
IReceiveRequest,
|
||||
IReceiveResponse,
|
||||
ISocket,
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
|
||||
/**
|
||||
* @module botframework-streaming
|
||||
*/
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
import { Duplex } from 'stream';
|
||||
import { INodeBuffer } from './INodeBuffer';
|
||||
|
||||
/**
|
||||
* Represents a Duplex from the `stream` module in Node.js.
|
||||
*
|
||||
* This interface supports the framework and is not intended to be called directly for your code.
|
||||
*/
|
||||
export interface INodeDuplex extends Duplex {
|
||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
on(event: 'data', listener: (chunk: INodeBuffer) => void): this;
|
||||
}
|
|
@ -7,152 +7,15 @@
|
|||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
import { INodeBuffer, ValidBuffer } from './INodeBuffer';
|
||||
import { IEventEmitter } from './IEventEmitter';
|
||||
import { Socket } from 'net';
|
||||
import { INodeBuffer } from './INodeBuffer';
|
||||
|
||||
/**
|
||||
* Represents a Socket from the `net` module in Node.js.
|
||||
*
|
||||
* This interface supports the framework and is not intended to be called directly for your code.
|
||||
*/
|
||||
export interface INodeSocket {
|
||||
connecting: boolean;
|
||||
destroyed: boolean;
|
||||
writable: boolean;
|
||||
readable: boolean;
|
||||
readonly bytesRead: number;
|
||||
readonly bufferSize: number;
|
||||
readonly bytesWritten: number;
|
||||
readonly localAddress: string;
|
||||
readonly localPort: number;
|
||||
readonly writableHighWaterMark: number;
|
||||
readonly writableLength: number;
|
||||
readonly readableHighWaterMark: number;
|
||||
readonly readableLength: number;
|
||||
readonly readableFlowing: boolean | null;
|
||||
|
||||
address(): AddressInfo | string;
|
||||
|
||||
connect(options: any, connectionListener?: () => void): any;
|
||||
connect(port: number, host: string, connectionListener?: () => void): any;
|
||||
connect(port: number, connectionListener?: () => void): any;
|
||||
connect(path: string, connectionListener?: () => void): any;
|
||||
|
||||
cork(): void;
|
||||
uncork(): void;
|
||||
|
||||
end(cb?: () => void): void;
|
||||
end(chunk: any, cb?: () => void): void;
|
||||
end(chunk: any, encoding?: string, cb?: () => void): void;
|
||||
|
||||
_destroy(error: Error | null, callback: (error: Error | null) => void): void;
|
||||
destroy(error?: Error): void;
|
||||
|
||||
pause(): this;
|
||||
resume(): this;
|
||||
isPaused(): boolean;
|
||||
unpipe(destination?: any): this;
|
||||
unshift(chunk: any): void;
|
||||
wrap(oldStream: any): this;
|
||||
push(chunk: any, encoding?: string): boolean;
|
||||
|
||||
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean }): T;
|
||||
|
||||
addListener(event: 'close', listener: () => void): this;
|
||||
addListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
addListener(event: 'end', listener: () => void): this;
|
||||
addListener(event: 'readable', listener: () => void): this;
|
||||
addListener(event: 'error', listener: (err: Error) => void): this;
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
emit(event: 'close'): boolean;
|
||||
emit(event: 'data', chunk: any): boolean;
|
||||
emit(event: 'end'): boolean;
|
||||
emit(event: 'readable'): boolean;
|
||||
emit(event: 'error', err: Error): boolean;
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
|
||||
eventNames(): Array<string | symbol>;
|
||||
_final(callback: (error?: Error | null) => void): void;
|
||||
listeners(event: string | symbol): Function[];
|
||||
listenerCount(type: string | symbol): number;
|
||||
|
||||
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
export interface INodeSocket extends Socket {
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: 'close', listener: (had_error: boolean) => void): this;
|
||||
on(event: 'connect', listener: () => void): this;
|
||||
on(event: 'data', listener: (data: INodeBuffer) => void): this;
|
||||
on(event: 'end', listener: () => void): this;
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
|
||||
once(event: 'close', listener: () => void): this;
|
||||
once(event: 'data', listener: (chunk: any) => void): this;
|
||||
once(event: 'end', listener: () => void): this;
|
||||
once(event: 'readable', listener: () => void): this;
|
||||
once(event: 'error', listener: (err: Error) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependListener(event: 'close', listener: () => void): this;
|
||||
prependListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
prependListener(event: 'end', listener: () => void): this;
|
||||
prependListener(event: 'readable', listener: () => void): this;
|
||||
prependListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
prependOnceListener(event: 'close', listener: () => void): this;
|
||||
prependOnceListener(event: 'data', listener: (chunk: any) => void): this;
|
||||
prependOnceListener(event: 'end', listener: () => void): this;
|
||||
prependOnceListener(event: 'readable', listener: () => void): this;
|
||||
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
rawListeners(event: string | symbol): Function[];
|
||||
|
||||
removeAllListeners(event?: string | symbol): this;
|
||||
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<any>;
|
||||
|
||||
_read(size: number): void;
|
||||
read(size?: number): any;
|
||||
|
||||
setDefaultEncoding(encoding: string): this;
|
||||
setEncoding(encoding: string): this;
|
||||
setMaxListeners(n: number): this;
|
||||
getMaxListeners(): number;
|
||||
setTimeout(timeout: number, callback?: () => void): this;
|
||||
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
||||
setNoDelay(noDelay?: boolean): this;
|
||||
|
||||
_write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
|
||||
_writev?(chunks: Array<{ chunk: any; encoding: string }>, callback: (error?: Error | null) => void): void;
|
||||
|
||||
write(buffer: ValidBuffer, cb?: (err?: Error) => void): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
write(buffer: ValidBuffer): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, fd?: string): boolean;
|
||||
write(data: any, encoding?: string, callback?: Function): void;
|
||||
write(chunk: any, cb?: (error: Error | null | undefined) => void): boolean;
|
||||
write(chunk: any, encoding?: string, cb?: (error: Error | null | undefined) => void): boolean;
|
||||
|
||||
ref(): any;
|
||||
unref(): any;
|
||||
}
|
||||
|
||||
interface AddressInfo {
|
||||
address: string;
|
||||
family: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
interface WritableStream extends IEventEmitter {
|
||||
writable: boolean;
|
||||
write(buffer: Buffer | string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
end(cb?: Function): void;
|
||||
end(buffer: Buffer, cb?: Function): void;
|
||||
end(str: string, cb?: Function): void;
|
||||
end(str: string, encoding?: string, cb?: Function): void;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
export * from './INodeBuffer';
|
||||
export * from './INodeIncomingMessage';
|
||||
export * from './INodeSocket';
|
||||
export * from './INodeDuplex';
|
||||
export * from './IReceiveRequest';
|
||||
export * from './IReceiveResponse';
|
||||
export * from './ISocket';
|
||||
|
|
|
@ -61,9 +61,8 @@ export class NamedPipeClient implements IStreamingTransportClient {
|
|||
const incomingPipeName: string =
|
||||
NamedPipeTransport.PipePath + this._baseName + NamedPipeTransport.ServerOutgoingPath;
|
||||
const incoming = connect(incomingPipeName);
|
||||
// TODO: Fix INodeSocket type. Related issue https://github.com/microsoft/botbuilder-js/issues/4684.
|
||||
this._sender.connect(new NamedPipeTransport(outgoing as any));
|
||||
this._receiver.connect(new NamedPipeTransport(incoming as any));
|
||||
this._sender.connect(new NamedPipeTransport(outgoing));
|
||||
this._receiver.connect(new NamedPipeTransport(incoming));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@ import { IncomingMessage, request } from 'http';
|
|||
import { URL } from 'url';
|
||||
import crypto from 'crypto';
|
||||
import WebSocket from 'ws';
|
||||
import { Socket } from 'net';
|
||||
|
||||
import { INodeIncomingMessage, INodeBuffer, INodeSocket, ISocket } from '../interfaces';
|
||||
|
||||
|
@ -36,12 +37,16 @@ export class NodeWebSocket implements ISocket {
|
|||
* @param head A Buffer [INodeBuffer](xref:botframework-streaming.INodeBuffer) interface.
|
||||
* @returns A Promise that resolves after the WebSocket upgrade has been handled, otherwise rejects with a thrown error.
|
||||
*/
|
||||
async create(req: INodeIncomingMessage, socket: INodeSocket, head: INodeBuffer): Promise<void> {
|
||||
async create(req: INodeIncomingMessage, socket: INodeSocket, head: INodeBuffer): Promise<void>;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async create(req: IncomingMessage, socket: Socket, head: Buffer): Promise<void> {
|
||||
this.wsServer = new WebSocket.Server({ noServer: true });
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
try {
|
||||
// TODO: Fix INodeSocket type. Related issue https://github.com/microsoft/botbuilder-js/issues/4684.
|
||||
this.wsServer.handleUpgrade(req as IncomingMessage, socket as any, head as any, (websocket) => {
|
||||
this.wsServer.handleUpgrade(req, socket, head, (websocket) => {
|
||||
this.wsSocket = websocket;
|
||||
resolve();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче