New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@illgrenoble/visa-print-server

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@illgrenoble/visa-print-server - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

dist/gateways/printer.gateway.d.ts

@@ -11,2 +11,3 @@ import { OnGatewayConnection, OnGatewayDisconnect, OnGatewayInit } from '@nestjs/websockets';

handlePrintJobHandled(client: Socket, jobId: number): void;
sendChunkedPrinterJob(printJobs: PrintJob[]): Promise<void>;
sendPrinterJob(printJob: PrintJob): Promise<void>;

@@ -16,2 +17,3 @@ afterInit(): void;

handleConnection(client: Socket): void;
private emit;
}

58

dist/gateways/printer.gateway.js

@@ -37,3 +37,10 @@ "use strict";

}
sendPrinterJob(printJob) {
async sendChunkedPrinterJob(printJobs) {
await this.emit('print_job_start');
for (const printJob of printJobs) {
await this.sendPrinterJob(printJob);
}
await this.emit('print_job_end');
}
async sendPrinterJob(printJob) {
const printerRoom = this.server.sockets.adapter.rooms.get('printer_clients');

@@ -44,25 +51,18 @@ if (!printerRoom || printerRoom.size == 0) {

}
return new Promise((resolve, reject) => {
this.server
.to('printer_clients')
.timeout(10000)
.emit('print', printJob, (err, responses) => {
if (err) {
this.logger.warn(`Received an error during send of chunk ${printJob.chunkId}/${printJob.chunkCount} of job ${printJob.jobId} data: ${err.message}`);
}
const okCount = responses.filter((response) => response === true).length;
if (okCount > 0) {
if (okCount === responses.length) {
this.logger.debug(`All ${responses.length} clients received correctly chunk ${printJob.chunkId}/${printJob.chunkCount} of job ${printJob.jobId}`);
}
else {
this.logger.warn(`Only ${okCount} / ${responses.length} clients received correctly chunk ${printJob.chunkId}/${printJob.chunkCount} of job ${printJob.jobId}`);
}
resolve();
}
else {
reject(new Error('No client sucessfully received the print job'));
}
});
});
const { error, responses } = await this.emit('print_job_data', printJob, 10000);
if (error) {
this.logger.warn(`Received an error during send of chunk ${printJob.chunkId}/${printJob.chunkCount} of job ${printJob.jobId} data: ${error.message}`);
}
const okCount = responses.filter((response) => response === true).length;
if (okCount > 0) {
if (okCount === responses.length) {
this.logger.debug(`All ${responses.length} clients received correctly chunk ${printJob.chunkId}/${printJob.chunkCount} of job ${printJob.jobId}`);
}
else {
this.logger.warn(`Only ${okCount} / ${responses.length} clients received correctly chunk ${printJob.chunkId}/${printJob.chunkCount} of job ${printJob.jobId}`);
}
}
else {
throw new Error('No client sucessfully received the print job');
}
}

@@ -78,2 +78,12 @@ afterInit() {

}
emit(message, data, timeout) {
return new Promise((resolve) => {
this.server
.to('printer_clients')
.timeout(timeout)
.emit(message, data, (error, responses) => {
resolve({ error, responses });
});
});
}
};

@@ -80,0 +90,0 @@ exports.PrinterGateway = PrinterGateway;

@@ -10,2 +10,3 @@ import { FileData } from '../types';

processJob(jobId: number, fileData: FileData): Promise<void>;
private createPrintJobs;
}

@@ -24,2 +24,14 @@ "use strict";

async processJob(jobId, fileData) {
const chunks = this.createPrintJobs(jobId, fileData);
try {
this.logger.log(`Transferring ${chunks.length} chunks for print job ${jobId} (file '${fileData.fileName}' of length ${fileData.length} bytes)`);
await this.printerGateway.sendChunkedPrinterJob(chunks);
this.logger.log(`Print job ${jobId} transferred successfully`);
}
catch (error) {
this.logger.error(`Received error during transfer of print job ${jobId}: ${error.message}`);
throw error;
}
}
createPrintJobs(jobId, fileData) {
const maxChunkLength = this.configService.get('ws').maxData;

@@ -52,13 +64,3 @@ let start = 0;

}
try {
this.logger.log(`Transferring ${chunks.length} chunks for print job ${jobId} (file '${fileData.fileName}' of length ${fileData.length} bytes)`);
for (const printJob of chunks) {
await this.printerGateway.sendPrinterJob(printJob);
}
this.logger.log(`Print job ${jobId} transferred successfully`);
}
catch (error) {
this.logger.error(`Received error during transfer of print job ${jobId}: ${error.message}`);
throw error;
}
return chunks;
}

@@ -65,0 +67,0 @@ };

{
"name": "@illgrenoble/visa-print-server",
"version": "1.0.0",
"version": "1.1.0",
"description": "A print server to transfer print jobs from a VISA instance to a print client via websocket",

@@ -38,3 +38,4 @@ "repository": {

"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
"test:e2e": "jest --config ./test/jest-e2e.json",
"publish": "npm run build && npm publish --access public"
},

@@ -41,0 +42,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc