Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Fix import exceptions from #482 #489

Merged
merged 2 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/sdk/src/actor/behaviors/buttonBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import {
ActionState,
BehaviorType,
DiscreteAction,
TargetBehavior,
User
} from '../..';
// break import cycle
import { TargetBehavior } from './targetBehavior';

/**
* Button behavior class containing the target behavior actions.
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/actor/behaviors/targetBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import {
ActionHandler,
ActionState,
Behavior,
BehaviorType,
DiscreteAction,
User
} from '../..';
// break import cycle
import { Behavior } from './behavior';

/**
* Target behavior class containing the target behavior actions.
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/asset/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import {
Actor,
Asset,
AssetContainer,
AssetLike,
Color3,
Expand All @@ -22,6 +21,8 @@ import {
readPath
} from '../internal';
import { AssetInternal } from './assetInternal';
// break import cycle
import { Asset } from './asset';

/**
* Describes the properties of a Material.
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/asset/mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import {
Actor,
Asset,
AssetContainer,
AssetLike,
PrimitiveDefinition,
Expand All @@ -14,6 +13,8 @@ import {
} from '..';
import { Patchable } from '../internal';
import { AssetInternal } from './assetInternal';
// break import cycle
import { Asset } from './asset';

/** Describes the properties of a mesh */
export interface MeshLike {
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/asset/prefab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* Licensed under the MIT License.
*/

import { Actor, Asset, AssetContainer, AssetLike } from '..';
import { Actor, AssetContainer, AssetLike } from '..';
import { Patchable } from '../internal';
import { AssetInternal } from './assetInternal';
// break import cycle
import { Asset } from './asset';

export interface PrefabLike {
/** The number of actors this prefab contains. */
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/asset/sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* Licensed under the MIT License.
*/

import { Actor, Asset, AssetContainer, AssetLike } from '..';
import { Actor, AssetContainer, AssetLike } from '..';
import { Patchable } from '../internal';
import { AssetInternal } from './assetInternal';
// break import cycle
import { Asset } from './asset';

export interface SoundLike {
uri: string;
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/asset/texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* Licensed under the MIT License.
*/

import { Actor, Asset, AssetContainer, AssetLike, Material, Vector2, Vector2Like } from '..';
import { Actor, AssetContainer, AssetLike, Material, Vector2, Vector2Like } from '..';
import { Patchable, readPath } from '../internal';
import { AssetInternal } from './assetInternal';
// break import cycle
import { Asset } from './asset';

export interface TextureLike {
uri: string;
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/asset/videoStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* Licensed under the MIT License.
*/

import { Actor, Asset, AssetContainer, AssetLike } from '..';
import { Actor, AssetContainer, AssetLike } from '..';
import { Patchable } from '../internal';
import { AssetInternal } from './assetInternal';
// break import cycle
import { Asset } from './asset';

export interface VideoStreamLike {
uri: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@ import {
ExportedPromise,
Message,
MissingRule,
Protocols,
Rules
} from '../../..';
// break import cycle
import { Heartbeat, Middleware, Protocol, ServerPreprocessing } from '../../../protocols';

/**
* @hidden
* Class for routing messages between the client and the session
*/
export class ClientExecution extends Protocols.Protocol implements Protocols.Middleware {
private heartbeat: Protocols.Heartbeat;
export class ClientExecution extends Protocol implements Middleware {
private heartbeat: Heartbeat;
private heartbeatTimer: NodeJS.Timer;

/** @override */
public get name(): string { return `${this.constructor.name} client ${this.client.id.substr(0, 8)}`; }

constructor(private client: Client) {
super(client.conn);
this.heartbeat = new Protocols.Heartbeat(this);
this.heartbeat = new Heartbeat(this);
this.beforeRecv = this.beforeRecv.bind(this);
// Behave like a server-side endpoint (send heartbeats, measure connection quality)
this.use(new Protocols.ServerPreprocessing());
this.use(new ServerPreprocessing());
// Filter user-exclusive actors
this.use(new ClientDesyncPreprocessor(client));
// Use middleware to pipe client messages to the session.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import {
Message,
MissingRule,
OperatingModel,
Protocols,
Rules
} from '../../..';
// break import cycle
import { Handshake } from '../../../protocols';

/**
* @hidden
*/
export class ClientHandshake extends Protocols.Handshake {
export class ClientHandshake extends Handshake {
/** @override */
public get name(): string { return `${this.constructor.name} client ${this.client.id.substr(0, 8)}`; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ import {
Message,
MissingRule,
Payloads,
Protocols,
Rules
} from '../../..';
// break import cycle
import { Heartbeat, Protocol, ServerPreprocessing } from '../../../protocols';

export class ClientStartup extends Protocols.Protocol {
export class ClientStartup extends Protocol {
/** @override */
public get name(): string { return `${this.constructor.name} client ${this.client.id.substr(0, 8)}`; }

constructor(private client: Client, syncRequest: Payloads.SyncRequest) {
super(client.conn);
// Behave like a server-side endpoint (send heartbeats, measure connection quality).
this.use(new Protocols.ServerPreprocessing());
this.use(new ServerPreprocessing());
// If we've already received the 'sync-request' payload, process it now.
if (syncRequest) {
setImmediate(async () => {
Expand All @@ -45,7 +46,7 @@ export class ClientStartup extends Protocols.Protocol {

private async performStartup(payload: Payloads.SyncRequest) {
// Do a quick measurement of connection latency.
const heartbeat = new Protocols.Heartbeat(this);
const heartbeat = new Heartbeat(this);
await heartbeat.runIterations(10); // Allow exceptions to propagate out.
this.resolve();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import {
Message,
MissingRule,
Payloads,
Protocols,
Rules,
SyncActor
} from '../../../../internal';
// break import cycle
import { Protocol, ServerPreprocessing } from '../../../protocols';

/**
* @hidden
Expand All @@ -36,7 +37,7 @@ export type SynchronizationStage =
* @hidden
* Synchronizes application state with a client.
*/
export class ClientSync extends Protocols.Protocol {
export class ClientSync extends Protocol {
private inProgressStages: SynchronizationStage[] = [];
private completedStages: SynchronizationStage[] = [];

Expand All @@ -56,7 +57,7 @@ export class ClientSync extends Protocols.Protocol {
constructor(private client: Client) {
super(client.conn);
// Behave like a server-side endpoint (send heartbeats, measure connection quality)
this.use(new Protocols.ServerPreprocessing());
this.use(new ServerPreprocessing());
// Queue up user-exclusive messages until the user has joined
this.use(new ClientDesyncPreprocessor(client));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
* Licensed under the MIT License.
*/

import { Message, Protocols, Session } from '../../../../internal';
import { Message, Session } from '../../../../internal';
// break import cycle
import { Middleware, Protocol, ClientPreprocessing } from '../../../protocols';

/**
* @hidden
* Class for routing messages from the app over to the session
*/
export class SessionExecution extends Protocols.Protocol implements Protocols.Middleware {
export class SessionExecution extends Protocol implements Middleware {
constructor(private session: Session) {
super(session.conn);
this.beforeRecv = this.beforeRecv.bind(this);
// Behave like a client-side endpoint (record latency, respond to heartbeats).
this.use(new Protocols.ClientPreprocessing(this));
this.use(new ClientPreprocessing(this));
// Use middleware to take incoming messages from the app and pipe them to the session.
this.use(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
* Licensed under the MIT License.
*/

import { Payloads, Protocols, Session } from '../../../../internal';
import { Payloads, Session } from '../../../../internal';
// break import cycle
import { Protocol, ClientPreprocessing } from '../../../protocols';

/**
* @hidden
* Protocol for handling handshake with the app instance (Session is a client of App)
*/
export class SessionHandshake extends Protocols.Protocol {
export class SessionHandshake extends Protocol {
constructor(session: Session) {
super(session.conn);
// Behave like a client-side endpoint (record latency, respond to heartbeats).
this.use(new Protocols.ClientPreprocessing(this));
this.use(new ClientPreprocessing(this));
}

/** @override */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
* Licensed under the MIT License.
*/

import { Payloads, Protocols, Session } from '../../../../internal';
import { Payloads, Session } from '../../../../internal';
// break import cycle
import { Protocol, ClientPreprocessing } from '../../../protocols';

/**
* @hidden
* Class to manage the synchronization phase when connecting to the app. There should be no state to synchronize
*/
export class SessionSync extends Protocols.Protocol {
export class SessionSync extends Protocol {
constructor(session: Session) {
super(session.conn);
// Behave like a client-side endpoint (record latency, respond to heartbeats).
this.use(new Protocols.ClientPreprocessing(this));
this.use(new ClientPreprocessing(this));
}

/** @override */
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/internal/connection/eventedConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import { EventEmitter } from 'events';
import { Guid } from '../..';
import {
Connection,
ConnectionQuality,
Message,
NetworkStatsReport,
NetworkStatsTracker,
QueuedPromise
} from '../../internal';
// break import cycle
import { Connection } from './connection';

/**
* @hidden
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/internal/connection/webSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import * as WS from 'ws';

import { log } from '../..';
import { EventedConnection, filterEmpty, Message, validateJsonFieldName } from '../../internal';
import { filterEmpty, Message, validateJsonFieldName } from '../../internal';
// break import cycle
import { EventedConnection } from './eventedConnection';

/**
* An implementation of the Connection interface that wraps a WebSocket.
Expand Down
12 changes: 8 additions & 4 deletions packages/sdk/src/internal/protocols/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
*/

import { ActionEvent, CollisionEvent, Context, log, TriggerEvent, } from '../..';
import { Message, Payloads, Protocols, WebSocket } from '../../internal';
import { Message, Payloads, WebSocket } from '../../internal';
// break import cycle
import { Protocol } from './protocol';
import { ServerPreprocessing } from './serverPreprocessing';
import { Sync } from './sync';

/**
* @hidden
* Class to handle operational messages with a client.
*/
export class Execution extends Protocols.Protocol {
export class Execution extends Protocol {
constructor(private context: Context) {
super(context.conn);
// Behave like a server-side endpoint (send heartbeats, measure connection quality)
this.use(new Protocols.ServerPreprocessing());
this.use(new ServerPreprocessing());
}

/** @override */
Expand Down Expand Up @@ -94,7 +98,7 @@ export class Execution extends Protocols.Protocol {
// Switch over to the Sync protocol to handle this request
this.stopListening();

const sync = new Protocols.Sync(this.conn);
const sync = new Sync(this.conn);
await sync.run(); // Allow exception to propagate.

this.startListening();
Expand Down
9 changes: 6 additions & 3 deletions packages/sdk/src/internal/protocols/handshake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
* Licensed under the MIT License.
*/

import { Connection, OperatingModel, Payloads, Protocols } from '../../internal';
import { Connection, OperatingModel, Payloads } from '../../internal';
// break import cycle
import { Protocol } from './protocol';
import { ServerPreprocessing } from './serverPreprocessing';

/**
* @hidden
* Class to manage the handshake process with a client.
*/
export class Handshake extends Protocols.Protocol {
export class Handshake extends Protocol {
public syncRequest: Payloads.SyncRequest;

constructor(conn: Connection, private sessionId: string, private operatingModel: OperatingModel) {
super(conn);
// Behave like a server-side endpoint (send heartbeats, measure connection quality)
this.use(new Protocols.ServerPreprocessing());
this.use(new ServerPreprocessing());
}

/** @private */
Expand Down
Loading