Skip to content
Merged

Dev #74

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dictionary/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hl7v2-dictionary",
"description": "HL7 v2 parser, serializer, validator for NodeJS",
"version": "1.7.1",
"version": "1.8.0",
"author": "Panates",
"license": "MIT",
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions packages/hl7v2/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hl7v2",
"description": "HL7 v2 parser, serializer, validator for NodeJS",
"version": "1.7.1",
"version": "1.8.0",
"author": "Panates",
"license": "MIT",
"private": true,
Expand All @@ -16,7 +16,7 @@
"uid": "^2.0.2"
},
"peerDependencies": {
"hl7v2-dictionary": "^1.7.1"
"hl7v2-dictionary": "^1.8.0"
},
"devDependencies": {
"expect": "^30.2.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/net/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hl7v2-net",
"description": "HL7 v2 server/client for NodeJS",
"version": "1.7.1",
"version": "1.8.0",
"author": "Panates",
"license": "MIT",
"private": true,
Expand All @@ -18,8 +18,8 @@
"uid": "^2.0.2"
},
"peerDependencies": {
"hl7v2": "^1.7.1",
"hl7v2-dictionary": "^1.7.1"
"hl7v2": "^1.8.0",
"hl7v2-dictionary": "^1.8.0"
},
"devDependencies": {
"@types/reconnect-core": "^1.3.5",
Expand Down
53 changes: 35 additions & 18 deletions packages/net/src/hl7-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,40 +115,44 @@ export class Hl7Client extends AsyncEventEmitter<Hl7Client.Events> {
return this._options.host + ':' + this._options.port;
}

address() {
return this._socket?.address();
get localAddress() {
return this._socket?.localAddress;
}

remoteAddress(): string {
return (
this._socket?.remoteAddress() ||
this._options.host + ':' + this._options.port
);
get localPort() {
return this._socket?.localPort;
}

get connectTimeout(): number | undefined {
return this._options.connectTimeout;
get localFamily() {
return this._socket?.localFamily;
}

set connectTimeout(value: number | null) {
this._options.connectTimeout = value ?? undefined;
get remoteAddress() {
return this._socket?.remoteAddress || this._options.host;
}

get responseTimeout(): number | undefined {
return this._options.responseTimeout;
get remotePort() {
return this._socket?.remotePort || this._options.port;
}

set responseTimeout(value: number | null) {
this._options.responseTimeout = value ?? undefined;
get remoteFamily() {
return this._socket?.remoteFamily;
}

get connectTimeout(): number | undefined {
return this._options.connectTimeout;
}

get responseTimeout(): number | undefined {
return this._options.responseTimeout;
}

get maxBufferSize(): number {
return this._options.maxBufferSize || 0;
}

set maxBufferSize(value: number) {
this._options.maxBufferSize = value;
if (this._socket) this._socket.maxBufferSize = value;
address() {
return this._socket?.address();
}

async connect(): Promise<void> {
Expand Down Expand Up @@ -189,6 +193,19 @@ export class Hl7Client extends AsyncEventEmitter<Hl7Client.Events> {
return this._socket!.sendMessageWaitAck(request);
}

setConnectTimeout(value: number | null) {
this._options.connectTimeout = value ?? undefined;
}

setResponseTimeout(value: number | null) {
this._options.responseTimeout = value ?? undefined;
}

setMaxBufferSize(value: number) {
this._options.maxBufferSize = value;
if (this._socket) this._socket.setMaxBufferSize(value);
}

setKeepAlive(enable?: boolean, initialDelay?: number) {
this._options.keepAlive = enable;
this._options.keepAliveInitialDelay = initialDelay;
Expand Down
4 changes: 0 additions & 4 deletions packages/net/src/hl7-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ export class HL7Request {
this.socket = socket;
this.message = message;
}

remoteAddress() {
return this.socket.remoteAddress();
}
}
30 changes: 25 additions & 5 deletions packages/net/src/hl7-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,39 @@ export class HL7Socket extends AsyncEventEmitter<HL7Socket.Events> {
return this._frameStream.maxBufferSize || 0;
}

set maxBufferSize(value: number) {
this._frameStream.maxBufferSize = value;
get localAddress() {
return this.socket?.localAddress;
}

address() {
return this.socket?.address() || {};
get localPort() {
return this.socket?.localPort;
}

get localFamily() {
return this.socket?.localFamily;
}

remoteAddress() {
get remoteAddress() {
const addr = this.socket?.remoteAddress;
return addr?.startsWith('::ffff:') ? addr.slice(7) : addr;
}

get remotePort() {
return this.socket?.remotePort;
}

get remoteFamily() {
return this.socket?.remoteFamily;
}

get writable() {
return this.connected && this.socket?.writable;
}

address() {
return this.socket?.address() || {};
}

async close(waitRunningHandlers?: number): Promise<void> {
if (this.closed) return;
/** Stop receiving data */
Expand Down Expand Up @@ -186,6 +202,10 @@ export class HL7Socket extends AsyncEventEmitter<HL7Socket.Events> {
this.socket.setKeepAlive(enable, initialDelay);
}

setMaxBufferSize(value: number) {
this._frameStream.maxBufferSize = value;
}

protected _onData(data: Buffer) {
try {
const message = new HL7Message();
Expand Down