@casual-simulation/aux-common
Version:
Common library for AUX projects
95 lines • 3.71 kB
TypeScript
import type { OtherPlayersClientPartitionConfig, OtherPlayersRepoPartitionConfig, PartitionConfig } from './AuxPartitionConfig';
import type { OtherPlayersPartition, AuxPartitionRealtimeStrategy } from './AuxPartition';
import type { BotsState, UpdatedBot, Bot, BotAction, StateUpdatedEvent } from '../bots';
import type { Observable } from 'rxjs';
import { Subject } from 'rxjs';
import type { InstRecordsClient } from '../websockets';
import type { Action, CurrentVersion, RemoteActions, StatusUpdate } from '../common';
import type { PartitionAuthSource } from './PartitionAuthSource';
export declare function createOtherPlayersClientPartition(config: PartitionConfig, authSource: PartitionAuthSource): Promise<OtherPlayersPartitionImpl>;
/**
* Defines a partition that watches for other players and loads their player partitions dynamically.
*/
export declare class OtherPlayersPartitionImpl implements OtherPlayersPartition {
protected _onBotsAdded: Subject<Bot[]>;
protected _onBotsRemoved: Subject<string[]>;
protected _onBotsUpdated: Subject<UpdatedBot[]>;
protected _onStateUpdated: Subject<StateUpdatedEvent>;
private _onVersionUpdated;
protected _onError: Subject<any>;
protected _onEvents: Subject<Action[]>;
protected _onStatusUpdated: Subject<StatusUpdate>;
protected _hasRegisteredSubs: boolean;
private _sub;
private _space;
private _recordName;
private _inst;
private _branch;
private _state;
private _skipInitialLoad;
private _authSource;
/**
* The map of branch names to partitions.
*/
private _partitions;
/**
* The map of branch names to promises that resolve when the partition is ready.
*/
private _partitionPromises;
/**
* The map of session IDs to connected devices.
*/
private _devices;
/**
* The map of branch names to subscriptions.
*/
private _partitionSubs;
/**
* Whether the partition is watching the branch.
*/
private _watchingBranch;
private _client;
private _synced;
private: boolean;
private _childParitionType;
get space(): string;
set space(value: string);
get realtimeStrategy(): AuxPartitionRealtimeStrategy;
get onBotsAdded(): Observable<Bot[]>;
get onBotsRemoved(): Observable<string[]>;
get onBotsUpdated(): Observable<UpdatedBot[]>;
get onStateUpdated(): Observable<StateUpdatedEvent>;
get onVersionUpdated(): Observable<CurrentVersion>;
get onError(): Observable<any>;
get onEvents(): Observable<Action[]>;
get onStatusUpdated(): Observable<StatusUpdate>;
unsubscribe(): void;
get closed(): boolean;
get state(): BotsState;
type: "other_players";
get forcedOffline(): boolean;
set forcedOffline(value: boolean);
constructor(client: InstRecordsClient, authSource: PartitionAuthSource, config: OtherPlayersClientPartitionConfig | OtherPlayersRepoPartitionConfig);
applyEvents(events: BotAction[]): Promise<BotAction[]>;
sendRemoteEvents(events: RemoteActions[]): Promise<void>;
connect(): void;
enableCollaboration(): Promise<void>;
private _loadWithoutConnecting;
private _watchDevices;
private _updateSynced;
private _registerDevice;
private _unregisterDevice;
/**
* Attempts to load the player branch for the given device.
* @param device The device.
*/
private _tryLoadBranchForDevice;
private _loadPartition;
/**
* Attempts to unload the player branch for the given device.
* @param device The device.
*/
private _tryUnloadBranchForDevice;
private _branchNameForDevice;
}
//# sourceMappingURL=OtherPlayersPartition.d.ts.map