Skip to content

[Streaming] Low-level hook for initializing WebSocket connection #1386

@stevengum

Description

@stevengum

Is your feature request related to a problem? Please describe.
The current way to set up a WebSocket connection via the BotFrameworkAdapter is to use processActivity(req, res, logic: async (context) => Promise<any>) which may call useWebSocket(req, res, logic: async (context) => Promise<any>).

The problem with the current implementation is that it ties useWebSocket() to the restify framework, which helpfully exposes the socket and head via ServerUpgradeResponse.claimUpgrade() method.

Other web service frameworks do not offer the same helper code.

The one shared feature most Node.js Web libraries offer is a way to listen for the "upgrade" event emitted from the http.Server.


Describe the solution you'd like
A low level entry-point for useWebSockets(). The updated signature may look like the following:

public async useWebSockets(req: http.IncomingMessage, socket: net.Socket, head: Buffer, logic: (context: TurnContext) => Promise<void>): Promise<void>

The current preview high-level entry-point BotFrameworkAdapter.processActivity() would not be used for WebSockets, only for regular HTTP requests.


Additional notes
Upgrade requests for WebSockets from Direct Line Speech only come in with GET requests. In the code, we would begin the authentication process if it's a valid Upgrade request using the GET method.

Requests with non-GET methods would simply pass through BotFrameworkAdapter.useWebSockets()


@christopheranderson, @carlosscastro, @DDEfromOR

Metadata

Metadata

Assignees

Labels

P1Painful if we don't fix, won't block releasingR7Release 7 - December 10th, 2019

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions