Implement zlib compression of ws messages
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import Logger from "../Logger";
|
||||
import {SessionManager} from "../SessionManager";
|
||||
import {SmppSession} from "../SmppSession";
|
||||
import ZlibCoder from "../ZlibCoder";
|
||||
|
||||
export class ClientSet {
|
||||
identifier: string;
|
||||
@@ -55,10 +56,11 @@ export class ClientSet {
|
||||
}
|
||||
|
||||
notifyClients(message: string) {
|
||||
let compressedMessage = ZlibCoder.compress(message);
|
||||
if (this.clients.length > 0) {
|
||||
this.logger.log2(`Notifying clients: ${message}`);
|
||||
this.clients.forEach((ws) => {
|
||||
ws.send(message);
|
||||
ws.send(compressedMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ const zlib = require("zlib");
|
||||
|
||||
export default class ZlibCoder {
|
||||
static compress(input: string): Buffer {
|
||||
return zlib.compress(input);
|
||||
return zlib.deflateSync(input).toString('base64');
|
||||
}
|
||||
|
||||
static decompress(input: Buffer): string {
|
||||
|
Reference in New Issue
Block a user