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): SyncRequestCreates a new sync request.
Parameters:#
| Name | Type | Description |
|---|---|---|
from | MapPlayer | The player to send the data from. |
Returns: SyncRequest
Defined in: system/sync.ts:116
new SyncRequest(from: MapPlayer, data: string): SyncRequestCreates a new sync request and immediately attempts to send the data.
Parameters:#
| Name | Type | Description |
|---|---|---|
from | MapPlayer | The player to send the data from. |
data | string | The 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(): numberGet the time that the sync request started syncing.
Returns: number
Defined in: system/sync.ts:153
Methods#
catch#
catch(callback: SyncCallback): SyncRequestSets the callback for when a request failed.
Parameters:#
| Name | Type | Description |
|---|---|---|
callback | SyncCallback |
Returns: SyncRequest
Defined in: system/sync.ts:161
destroy#
destroy(): voidRecycles the request index and prevents it from sending any more data.
Returns: void
Defined in: system/sync.ts:169
start#
start(data: string): booleanStart syncing
Parameters:#
| Name | Type | Description |
|---|---|---|
data | string | The 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): SyncRequestSets the callback for when a request has sucessfully synchronized.
Parameters:#
| Name | Type | Description |
|---|---|---|
callback | SyncCallback |
Returns: SyncRequest
Defined in: system/sync.ts:217
fromIndex#
static fromIndex(index: number): SyncRequestRetrieve a request based on it's index
Parameters:#
| Name | Type | Description |
|---|---|---|
index | number | The request index |
Returns: SyncRequest
Defined in: system/sync.ts:251