-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: streaming client should connect under Node.js (#4413)
* Fix NodeWebSocket.connect * Fix ESLint * Update API * Remove .only * Clean up code related to watershed * Fix ESLint * Fix tests for Node.js 12 * Fix ESLint * Add mocks * Remove .only * Use LF * Detect older signature * Fix ESLint * serverAddress become serverAddressOrHostName * Update API * Clean up * More clean up * Clean up * Leaving old code * Switching branch * Clean up * Clean up * Clean up * Manual edit
- Loading branch information
Showing
9 changed files
with
229 additions
and
39 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
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
6 changes: 3 additions & 3 deletions
6
libraries/botframework-streaming/tests/NodeWebSocketFactory.test.js
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
15 changes: 15 additions & 0 deletions
15
libraries/botframework-streaming/tests/helpers/fauxSocket.js
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,15 @@ | ||
const { Duplex } = require('stream'); | ||
|
||
module.exports.FauxSocket = class FauxSocket extends Duplex { | ||
// eslint-disable-next-line no-empty | ||
_read() {} | ||
|
||
// eslint-disable-next-line no-empty | ||
_write() {} | ||
|
||
// eslint-disable-next-line no-empty | ||
setNoDelay() {} | ||
|
||
// eslint-disable-next-line no-empty | ||
setTimeout() {} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports.sleep = function sleep(durationInMS = 100) { | ||
return new Promise((resolve) => setTimeout(resolve, durationInMS)); | ||
}; |
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,16 @@ | ||
const { sleep } = require('./sleep'); | ||
|
||
module.exports.waitFor = async function waitFor(callback, { interval = 50, timeout = 1000 } = {}) { | ||
let lastError; | ||
|
||
for (const startTime = Date.now(); Date.now() < startTime + timeout; ) { | ||
try { | ||
return callback(); | ||
} catch (error) { | ||
lastError = error; | ||
await sleep(interval); | ||
} | ||
} | ||
|
||
throw lastError || new Error('timed out'); | ||
}; |