|
@@ -4,6 +4,8 @@ import { StorageLocation } from '../types/interface';
|
|
|
import { Server } from 'socket.io'
|
|
|
import { io } from 'socket.io-client';
|
|
|
import { UtilityService } from '../services/utility.service';
|
|
|
+import { Worker } from "worker_threads"
|
|
|
+
|
|
|
|
|
|
let msgData = new DataPrepService()
|
|
|
let util = new UtilityService()
|
|
@@ -30,8 +32,23 @@ function createWebsocketServer() {
|
|
|
const subscription = msgPayload.pipe(
|
|
|
buffer(notifier)
|
|
|
).subscribe((element) => {
|
|
|
- console.log(`Emitting ${element.length} messages`)
|
|
|
- socket.emit(`payload`, element);
|
|
|
+ if (element.length >= 25000) {
|
|
|
+ const chunkSize = 1024; // Specify the desired chunk size in bytes
|
|
|
+ const totalChunks = Math.ceil(element.length / chunkSize);
|
|
|
+
|
|
|
+ Array.from({ length: totalChunks }, (_, i) => {
|
|
|
+ const start = i * chunkSize;
|
|
|
+ const end = start + chunkSize;
|
|
|
+ const chunk = element.slice(start, end);
|
|
|
+
|
|
|
+ console.log(`Emitting ${element.length} messages`)
|
|
|
+ socket.emit('payload', chunk);
|
|
|
+ });
|
|
|
+ socket.emit(`end`)
|
|
|
+ } else {
|
|
|
+ console.log(`Emitting ${element.length} messages`)
|
|
|
+ socket.emit(`payload`, element);
|
|
|
+ }
|
|
|
|
|
|
});
|
|
|
|