3.5.1 • Published 24 days ago

@duet3d/connectors v3.5.1

Weekly downloads
-
License
LGPL-2.1
Repository
github
Last release
24 days ago

Connectors

TypeScript implementation of the Duet3D HTTP connectors.

Installation

Install via npm install @duet3d/connectors.

Bug reports

Please use the forum for support requests or the DuetWebControl GitHub repository for feature requests and bug reports.

Usage

The connector works for both Duets in SBC and standalone mode. Usage is as simple as:

import { connect, BaseConnector, Callbacks, DefaultSettings } from "@duet3d/connectors";
import ObjectModel from "@duet3d/objectmodel";

// use initial settings
const settings = {
    ...DefaultSettings,
    // your custom settings
};

// try to establish a connection
let connector: BaseConnector;
try {
    const connector = connect(location.hostname, settings);
} catch (e) {
    console.error("Failed to establish connection: " + e);
    return;
}

// load settings from the machine - you can then update "settings" from your loaded settings again

// set up object model instance and stay updated via callbacks
const model = new ObjectModel();
connector.setCallbacks({
    onConnectProgress: function (connector: BaseConnector, progress: number): void {
        if (progress === -1) {
            console.log("Connection attempt complete");
        } else {
            console.log("Connection progress: " + progress + "%");
        }
    },
    onConnectionError: function (connector: BaseConnector, reason: unknown): void {
        console.log("Connection error: " + reason);
        // TODO call connector.reconnect in given intervals
    },
    onReconnected: function (connector: BaseConnector): void {
        console.log("Connection established again");
    },
    onUpdate: function (connector: BaseConnector, data: any): void {
        // Note that this is called before the final connector instance is returned!
        model.update(data);
    },
    onVolumeChanged: function (connector: BaseConnector, volumeIndex: number): void {
        // TODO reload file browser lists of the given volume
    }
});

// do whatever you want to do with the session, see BaseConnector API
3.5.1

24 days ago

3.5.0

27 days ago

3.6.0-beta.7

1 month ago

3.6.0-beta.6

1 month ago

3.6.0-beta.5

1 month ago

3.6.0-beta.4

1 month ago

3.6.0-beta.3

1 month ago

3.6.0-beta.2

1 month ago

3.6.0-beta.1

1 month ago