-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* replaced new Server with createNodeServer(); created test INodeSocket2 for type hint * removed new Func unit test * consolidated server-creation into 1 utils module; added unit tests * removed await from Promise.all, as it was originally * Update libraries/botframework-streaming/tests/NamedPipe.test.js Co-Authored-By: Christopher Anderson <chrande@microsoft.com> * replaced references to @types/node classes with bf-streaming interfaces, minus for the static methods on Buffer and nodeWebSocket.create() * added more signatures to INodeSocket to remove Socket type dependency from WebSocketTransport * cleaned up comment * changed INodeSocket.connect() to return any, as the nested types on signature made it unsuitable to be a Socket (we are not creating interfaces for the multiple layers of node types * changed Buffer to INodeBuffer type hint * added type guards to ensure we're getting an INodeServer back from createNodeServer * added unit test * added duck typing checks for server methods * Added methods to INodeSocket to remove dependency on node stream.Duplex type * put server-creation in trycatch block, as we don't know if node 'net' module might change their Server ctor overloads * removed space from top of imports in tests * added false path to checks (whoops, forgot them) * moved imort below comment Co-authored-by: Christopher Anderson <chrande@microsoft.com> Co-authored-by: Steven Ickman <stevenic@microsoft.com>
- Loading branch information
1 parent
8a7456e
commit cc6d78e
Showing
19 changed files
with
397 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
libraries/botframework-streaming/src/interfaces/IEventEmitter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @module botframework-streaming | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
/** | ||
* Represents a EventEmitter 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 IEventEmitter { | ||
addListener(event: string | symbol, listener: (...args: any[]) => void): this; | ||
on(event: string | symbol, listener: (...args: any[]) => void): this; | ||
once(event: string | symbol, listener: (...args: any[]) => void): this; | ||
removeListener(event: string | symbol, listener: (...args: any[]) => void): this; | ||
off(event: string | symbol, listener: (...args: any[]) => void): this; | ||
removeAllListeners(event?: string | symbol): this; | ||
setMaxListeners(n: number): this; | ||
getMaxListeners(): number; | ||
listeners(event: string | symbol): Function[]; | ||
rawListeners(event: string | symbol): Function[]; | ||
emit(event: string | symbol, ...args: any[]): boolean; | ||
listenerCount(type: string | symbol): number; | ||
// Added in Node 6... | ||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this; | ||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; | ||
eventNames(): Array<string | symbol>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
libraries/botframework-streaming/src/interfaces/INodeServer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @module botframework-streaming | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { IEventEmitter } from '.'; | ||
|
||
/** | ||
* Represents a Server 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 INodeServer extends IEventEmitter { | ||
constructor: this; | ||
close(callback?: (err?: Error) => void): this; | ||
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this; | ||
listen(path: string, listeningListener?: () => void): this; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.