def __init__(
     self,
     conversation_reference: ConversationReference,
     credentials: MicrosoftAppCredentials,
 ):
     self._conversation_reference = conversation_reference
     self._connector_client = ConnectorClient(
         credentials, base_url=conversation_reference.service_url
     )
Beispiel #2
0
    def _get_or_create_connector_client(
            self, service_url: str,
            credentials: AppCredentials) -> ConnectorClient:
        if not credentials:
            credentials = MicrosoftAppCredentials.empty()

        # Get ConnectorClient from cache or create.
        client_key = BotFrameworkAdapter.key_for_connector_client(
            service_url, credentials.microsoft_app_id, credentials.oauth_scope)
        client = self._connector_client_cache.get(client_key)
        if not client:
            client = ConnectorClient(credentials, base_url=service_url)
            client.config.add_user_agent(USER_AGENT)
            self._connector_client_cache[client_key] = client

        return client
Beispiel #3
0
    async def create(
            self,
            service_url: str,
            audience: str  # pylint: disable=unused-argument
    ) -> ConnectorClient:
        if not self._service_url:
            self._service_url = service_url
        elif service_url != self._service_url:
            raise RuntimeError(
                "This is a streaming scenario, all connectors from this factory must all be for the same url."
            )

        # TODO: investigate if Driver and pipeline should be moved here
        streaming_driver = StreamingHttpDriver(self._request_handler)
        config = BotFrameworkConnectorConfiguration(
            MicrosoftAppCredentials.empty(),
            service_url,
            pipeline_type=AsyncBfPipeline,
            driver=streaming_driver,
        )
        streaming_driver.config = config
        connector_client = ConnectorClient(None, custom_configuration=config)

        return connector_client