How to use botframework-streaming - 4 common examples

To help you get started, we’ve selected a few botframework-streaming examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / botbuilder-js / libraries / botbuilder / src / botFrameworkAdapter.ts View on Github external
public async useWebSocket(req: WebRequest, socket: INodeSocket, head: INodeBuffer, logic: (context: TurnContext) => Promise): Promise {   
        // Use the provided NodeWebSocketFactoryBase on BotFrameworkAdapter construction,
        // otherwise create a new NodeWebSocketFactory.
        const webSocketFactory = this.webSocketFactory || new NodeWebSocketFactory();

        if (!logic) {
            throw new Error('Streaming logic needs to be provided to `useWebSocket`');
        }

        this.logic = logic;

        try {
            await this.authenticateConnection(req, this.settings.channelService);
        } catch (err) {
            // If the authenticateConnection call fails, send back the correct error code and close
            // the connection.
            if (typeof(err.message) === 'string' && err.message.toLowerCase().startsWith('unauthorized')) {
                abortWebSocketUpgrade(socket, 401);
            } else if (typeof(err.message) === 'string' && err.message.toLowerCase().startsWith(`'authheader'`)) {
                abortWebSocketUpgrade(socket, 400);
github microsoft / botbuilder-js / libraries / botbuilder / src / botFrameworkAdapter.ts View on Github external
private async startWebSocket(socket: ISocket): Promise{
        this.streamingServer = new WebSocketServer(socket, this);
        await this.streamingServer.start();
    }
github microsoft / botbuilder-js / libraries / botbuilder / src / botFrameworkAdapter.ts View on Github external
public async useNamedPipe(logic: (context: TurnContext) => Promise, pipeName: string = defaultPipeName): Promise {
        if (!logic) {
            throw new Error('Bot logic needs to be provided to `useNamedPipe`');
        }

        this.logic = logic;

        this.streamingServer = new NamedPipeServer(pipeName, this);
        await this.streamingServer.start();
    }
github microsoft / botbuilder-js / libraries / botbuilder / src / botFrameworkAdapter.ts View on Github external
public async processRequest(request: IReceiveRequest): Promise {
        let response = new StreamingResponse();

        if (!request) {
            response.statusCode = StatusCodes.BAD_REQUEST;
            response.setBody(`No request provided.`);
            return response;
        }

        if (!request.verb || !request.path) {
            response.statusCode = StatusCodes.BAD_REQUEST;
            response.setBody(`Request missing verb and/or path. Verb: ${ request.verb }. Path: ${ request.path }`);
            return response;
        }

        if (request.verb.toLocaleUpperCase() !== POST && request.verb.toLocaleUpperCase() !== GET) {
            response.statusCode = StatusCodes.METHOD_NOT_ALLOWED;
            response.setBody(`Invalid verb received. Only GET and POST are accepted. Verb: ${ request.verb }`);

botframework-streaming

Streaming library for the Microsoft Bot Framework

MIT
Latest version published 21 days ago

Package Health Score

93 / 100
Full package analysis