Class: ClientFactory

ClientFactory

new ClientFactory(opts)

Parameters:
Name Type Description
opts Object Options for this factory
Properties
Name Type Attributes Description
sdk * <optional>
The Matrix JS SDK require() to use.
url string <optional>
The Client-Server base HTTP URL. This must be set prior to calling getClientAs(). See configure() to set this after instantiation.
token string <optional>
The application service token to use. This must be set prior to calling getClientAs(). See configure() to set this after instantiation.
appServiceUserId string <optional>
The application service's user ID. Must be set prior to calling getClientAs(). See configure() to set this after instantiation.
Source:

Methods

configure(baseUrl, appServiceToken, appServiceUserId)

Configure the factory for generating clients.
Parameters:
Name Type Description
baseUrl string The base URL to create clients with.
appServiceToken string The AS token to use as the access_token
appServiceUserId string The AS's user_id
Source:

getClientAs(userIdnullable, requestopt)

Construct a new Matrix JS SDK Client. Calling this twice with the same args will return the *same* client instance.
Parameters:
Name Type Attributes Description
userId string <nullable>
Required. The user_id to scope the client to. A new client will be created per user ID. If this is null, a client scoped to the application service *itself* will be created.
request Request <optional>
Optional. The request ID to additionally scope the client to. If set, this will create a new client per user ID / request combo. This factory will dispose the created client instance when the request is resolved.
Source:

setLogFunction(func)

Set a function to be called when logging requests and responses.
Parameters:
Name Type Description
func function The function to invoke. The first arg is the string to log. The second arg is a boolean which is 'true' if the log is an error.
Source: