Class: SyncRequest#

A system which provides an easy way to synchronize data between game clients. The data will be split into chunks and sent in order until all of them are recieved by every player. Splitting the data is required as BlzSendSyncData only allows 255 characters per request.

example

const data = File.read("savecode.txt");
// Synchronize the contents of the file from the first player's computer.
new SyncRequest(Players[0], data).then((res, req) => {
print(res.data);
});

Hierarchy#

  • SyncRequest

Constructors#

constructor#

new SyncRequest(from: MapPlayer): SyncRequest

Creates a new sync request.

Parameters:#

NameTypeDescription
fromMapPlayerThe player to send the data from.

Returns: SyncRequest

Defined in: system/sync.ts:116

new SyncRequest(from: MapPlayer, data: string): SyncRequest

Creates a new sync request and immediately attempts to send the data.

Parameters:#

NameTypeDescription
fromMapPlayerThe player to send the data from.
datastringThe data to send.

Returns: SyncRequest

Defined in: system/sync.ts:122

Properties#

from#

• Readonly from: MapPlayer

Defined in: system/sync.ts:100


id#

• Readonly id: number

Defined in: system/sync.ts:101


options#

• Readonly options: ISyncOptions

Defined in: system/sync.ts:102

Accessors#

startTime#

startTime(): number

Get the time that the sync request started syncing.

Returns: number

Defined in: system/sync.ts:153

Methods#

catch#

catch(callback: SyncCallback): SyncRequest

Sets the callback for when a request failed.

Parameters:#

NameTypeDescription
callbackSyncCallback

Returns: SyncRequest

Defined in: system/sync.ts:161


destroy#

destroy(): void

Recycles the request index and prevents it from sending any more data.

Returns: void

Defined in: system/sync.ts:169


start#

start(data: string): boolean

Start syncing

Parameters:#

NameTypeDescription
datastringThe data to sync. If data was passed to the constructor then nothing will happen.

Returns: boolean

Defined in: system/sync.ts:179


then#

then(callback: SyncCallback): SyncRequest

Sets the callback for when a request has sucessfully synchronized.

Parameters:#

NameTypeDescription
callbackSyncCallback

Returns: SyncRequest

Defined in: system/sync.ts:217


fromIndex#

static fromIndex(index: number): SyncRequest

Retrieve a request based on it's index

Parameters:#

NameTypeDescription
indexnumberThe request index

Returns: SyncRequest

Defined in: system/sync.ts:251