import Connection from 'itslanguage/administrative-sdk/connection/connection-controller.js'
Connection
Controller class for managing connection interaction.
Static Method Summary
Static Public Methods | ||
public static |
logRPCError(result: Object) Log an error caught from an RPC call. |
Static Private Methods | ||
private static |
Logs browser compatibility for required and optional SDK capabilities. |
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) |
Member Summary
Private Members | ||
private |
_analysisId: * |
|
private |
_connection: * |
|
private |
_emitter: * |
|
private |
|
|
private |
_recordingId: * |
|
private |
|
Method Summary
Public Methods | ||
public |
addAccessToken(url: string): string Add an access token to the given URL. |
|
public |
addEventListener(name: string, handler: Function) Add an event listener. |
|
public |
Make an RPC to active current session. |
|
public |
cancelStreaming(recorder: AudioRecorder) Cancel any current streaming audio recording. |
|
public |
getOauth2Token(auth: BasicAuth | EmailCredentials, scope: string): Promise Ask the server for an OAuth2 token. |
|
public |
getUserAuth(auth: BasicAuth | EmailCredentials, organisationId: string): * Request authentication for a User. |
|
public |
removeEventListener(name: string, handler: Function) Remove an event listener of the websocket connection. |
|
public |
Create a connection to the websocket server. |
|
public |
|
Private Methods | ||
private |
_secureAjaxDelete(url: string): Promise Perform a HTTP DELETE to the API using authentication. |
|
private |
_secureAjaxGet(url: string): Promise Perform a HTTP GET to the API using authentication. |
|
private |
_secureAjaxPost(url: string, formdata: FormData): Promise Perform a HTTP POST to the API using authentication. |
|
private |
Fire an event. |
Static Public Methods
public static logRPCError(result: Object) source
Log an error caught from an RPC call.
Params:
Name | Type | Attribute | Description |
result | Object | Error object. |
Static Private Methods
Public Constructors
public constructor(options: Object) source
Params:
Name | Type | Attribute | Description |
options | Object | Options to configure the connection with. Valid options include:
|
Private Members
private _analysisId: * source
private _connection: * source
private _emitter: * source
private _recognitionId: * source
private _recordingId: * source
Public Methods
public addAccessToken(url: string): string source
Add an access token to the given URL.
Params:
Name | Type | Attribute | Description |
url | string | The URL to add an access token to. |
public addEventListener(name: string, handler: Function) source
Add an event listener. Listens to events emitted from the websocket server connection.
public call(rpc: string, args: ...any): Promise source
Make an RPC to active current session.
Params:
Name | Type | Attribute | Description |
rpc | string | The RPC to call. It will be prefixed with |
|
args | ...any | Any arguments to pass to the RPC. |
public cancelStreaming(recorder: AudioRecorder) source
Cancel any current streaming audio recording.
Params:
Name | Type | Attribute | Description |
recorder | AudioRecorder | The audio recorder currently recording. |
public getOauth2Token(auth: BasicAuth | EmailCredentials, scope: string): Promise source
Ask the server for an OAuth2 token.
Params:
Name | Type | Attribute | Description |
auth | BasicAuth | EmailCredentials |
|
Auth to obtain credentials from. If omitted we assume impersonation. |
scope | string |
|
The scope which should be available for the requested token. If omitted the current user will be used. |
Throw:
Promise.<Error> |
If the server returned an error. |
public getUserAuth(auth: BasicAuth | EmailCredentials, organisationId: string): * source
Request authentication for a User. This will either work for users with BasicAuth or for users with EmailCredentials (EmailAuth).
This method also generates the appropriate scope for the given params.
Params:
Name | Type | Attribute | Description |
auth | BasicAuth | EmailCredentials | Auth to obtain credentials from. |
|
organisationId | string |
|
Id of the organisation this user is part of. |
Return:
* |
public removeEventListener(name: string, handler: Function) source
Remove an event listener of the websocket connection.
public webSocketDisconnect() source
Private Methods
private _secureAjaxDelete(url: string): Promise source
Perform a HTTP DELETE to the API using authentication.
Params:
Name | Type | Attribute | Description |
url | string | Url to submit to. |
Throw:
Promise.<Error> |
If the server returned an error. |
private _secureAjaxGet(url: string): Promise source
Perform a HTTP GET to the API using authentication.
Params:
Name | Type | Attribute | Description |
url | string | Url to retrieve. |
Throw:
Promise.<Error> |
If the server returned an error. |