@pureweb/platform-streaming-agent
Version:
The PureWeb platform streaming agent enables your game to communicate and stream through the PureWeb Platform
24 lines (23 loc) • 869 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuntimeExtension = void 0;
const IExtension_1 = require("../../IExtension");
const ConnectionStates_1 = require("../../ConnectionStates");
/**
* Extension to monitor the runtime of the agent. It will trigger a state change event when the maximum runtime is reached.
*/
class RuntimeExtension extends IExtension_1.AbstractExtension {
constructor() {
super();
this.start = async () => {
setTimeout(() => {
this.connectionStateChange?.(ConnectionStates_1.ConnectionStates.MAXIMUM_RUNTIME_REACHED);
}, this.config.maximumRuntime * 1000);
return Promise.resolve(true);
};
}
onStateChanged(handler) {
this.connectionStateChange = handler;
}
}
exports.RuntimeExtension = RuntimeExtension;
;