UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

77 lines (76 loc) 2.35 kB
import { __decorate } from "tslib"; import { byte, stringNull } from '../decorators'; import { SendablePacket } from './base'; import { PacketType } from './enums'; /** * ScreenSHot * * You can instruct LFS to save a screenshot in data\shots using the IS_SSH packet. * * It will be saved as bmp / jpg / png as set in Misc Options. * Name can be a filename (excluding extension) or zero - LFS will create a name. * * LFS will reply with another IS_SSH when the request is completed. */ export class IS_SSH extends SendablePacket { constructor(data) { super(); this.Size = 40; this.Type = PacketType.ISP_SSH; /** Request: non-zero / reply: same value returned */ this.ReqI = 0; /** 0 = OK / other values see {@link ScreenshotError} */ this.Error = 0; this.Sp0 = 0; this.Sp1 = 0; this.Sp2 = 0; this.Sp3 = 0; /** Name of screenshot file - last byte must be zero */ this.Name = ''; this.initialize(data); } pack() { if (this.ReqI === 0) { throw new RangeError('IS_SSH - ReqI must be greater than 0'); } return super.pack(); } } __decorate([ byte() ], IS_SSH.prototype, "Size", void 0); __decorate([ byte() ], IS_SSH.prototype, "Type", void 0); __decorate([ byte() ], IS_SSH.prototype, "ReqI", void 0); __decorate([ byte() ], IS_SSH.prototype, "Error", void 0); __decorate([ byte() ], IS_SSH.prototype, "Sp0", void 0); __decorate([ byte() ], IS_SSH.prototype, "Sp1", void 0); __decorate([ byte() ], IS_SSH.prototype, "Sp2", void 0); __decorate([ byte() ], IS_SSH.prototype, "Sp3", void 0); __decorate([ stringNull(32) ], IS_SSH.prototype, "Name", void 0); export var ScreenshotError; (function (ScreenshotError) { /** OK: completed instruction */ ScreenshotError[ScreenshotError["SSH_OK"] = 0] = "SSH_OK"; /** Can't save a screenshot - dedicated host */ ScreenshotError[ScreenshotError["SSH_DEDICATED"] = 1] = "SSH_DEDICATED"; /** {@link IS_SSH} corrupted (e.g. Name does not end with zero) */ ScreenshotError[ScreenshotError["SSH_CORRUPTED"] = 2] = "SSH_CORRUPTED"; /** Could not save the screenshot */ ScreenshotError[ScreenshotError["SSH_NO_SAVE"] = 3] = "SSH_NO_SAVE"; })(ScreenshotError || (ScreenshotError = {}));