Skip to content

feat(node-hl7-server): expose underlying socket on InboundRequest#15

Open
sleistner wants to merge 1 commit into
Bugs5382:mainfrom
combinaut:feat/inbound-request-socket-accessor
Open

feat(node-hl7-server): expose underlying socket on InboundRequest#15
sleistner wants to merge 1 commit into
Bugs5382:mainfrom
combinaut:feat/inbound-request-socket-accessor

Conversation

@sleistner
Copy link
Copy Markdown

Summary

Add a socket field to InboundRequestProps and a corresponding InboundRequest.getSocket() accessor so handlers can reach the underlying TCP/TLS socket the message arrived on.

The Inbound listener already holds the live socket while it constructs the request and response objects; this PR just forwards it through to the handler. Useful when the handler needs peer/local address pairs to make routing decisions that depend on connection-level metadata rather than message content.

What changes

  • InboundRequestProps gains socket: Socket.
  • InboundRequest stores it and exposes getSocket(): Socket.
  • The two new InboundRequest(...) call sites in Inbound (in _handleMessages and the single-message path of _onTcpClientConnected) now pass the active socket.

The change is additive: existing consumers that ignore the new method are unaffected. Callers constructing InboundRequest directly (only seen in tests) must now include socket in the props.

Test plan

  • Existing InboundRequest tests updated to pass the new prop.
  • New InboundRequest - socket accessor returns the socket test verifies the accessor wires through correctly.

Add a `socket` field to `InboundRequestProps` and a corresponding
`InboundRequest.getSocket()` accessor so handlers can reach the
underlying TCP/TLS socket the message arrived on.

The `Inbound` listener already holds the live socket while it
constructs the request and response objects; this change just
forwards it through to the handler. Useful when the handler needs
peer/local address pairs to make routing decisions that depend on
connection-level metadata rather than message content.

## What changes

- `InboundRequestProps` adds `socket: Socket`.
- `InboundRequest` stores it and exposes `getSocket(): Socket`.
- The two `new InboundRequest(...)` call sites in `Inbound`
  (`_handleMessages` and the single-message path in
  `_onTcpClientConnected`) now pass the active socket.

The change is additive: existing consumers that ignore the new
method are unaffected. Callers constructing `InboundRequest`
directly (only seen in tests) must now include `socket` in the
props.

## Test plan

- Existing tests updated to pass the new prop.
- New `InboundRequest - socket accessor returns the socket` test
  verifies the accessor wires through correctly.
@Bugs5382 Bugs5382 self-assigned this May 1, 2026
@Bugs5382 Bugs5382 added the enhancement New feature or request label May 1, 2026
@Bugs5382
Copy link
Copy Markdown
Owner

Bugs5382 commented May 1, 2026

@sleistner I swear I added this. Will do once I merge in my major changes.

@Bugs5382
Copy link
Copy Markdown
Owner

@sleistner can you put this into the v4.0.0 branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants