Skip to main content

Class: BaseClient

BaseClient is the base class for any client tasked with interacting with =nil; BaseClient

Extended by

Constructors

new BaseClient()

new BaseClient(config): BaseClient

Creates an instance of BaseClient.

Parameters

ParameterTypeDescription

config

IClientBaseConfig

The config to be used in the client. It contains the transport and the shard ID. See IClientBaseConfig.

Returns

BaseClient

Defined

@nilfoundation/niljs/src/clients/BaseClient.ts:33

Properties

shardId?

protected optional shardId: number;

The ID of the shard with which the client needs to interact. The shard with this ID will be used in every call made by the client.

Defined

@nilfoundation/niljs/src/clients/BaseClient.ts:26


transport

protected transport: ITransport;

The ITransport to be used in the client. See ITransport.

Defined

@nilfoundation/niljs/src/clients/BaseClient.ts:18

Methods

getShardId()

getShardId(): undefined | number

Returns the shard ID.

Returns

undefined | number

The shard ID.

Defined

@nilfoundation/niljs/src/clients/BaseClient.ts:51


request()

protected request<T>(requestObject): Promise<T>

Sends a request.

Type Parameters

Type Parameter

T

Parameters

ParameterTypeDescription

requestObject

RequestArguments

The request object. It contains the request method and parameters.

Returns

Promise<T>

The response.

Defined

@nilfoundation/niljs/src/clients/BaseClient.ts:43


setShardId()

setShardId(shardId): void

Sets the shard ID.

Parameters

ParameterTypeDescription

shardId

number

The shard ID.

Returns

void

Throws

Will throw an error if the provided shard ID is invalid.

Example

client.setShardId(1);

Defined

@nilfoundation/niljs/src/clients/BaseClient.ts:62