HL7-3: remove optimistic updates #5
1 changed files with 14 additions and 2 deletions
|
@ -39,7 +39,7 @@ const clients = new Map();
|
||||||
|
|
||||||
console.log(`Starting WebSocket server ...`);
|
console.log(`Starting WebSocket server ...`);
|
||||||
|
|
||||||
console.log("Server configuration:", config);
|
console.log('Server configuration:', config);
|
||||||
|
|
||||||
wss.on('connection', (ws) => {
|
wss.on('connection', (ws) => {
|
||||||
|
|
||||||
|
@ -105,17 +105,29 @@ wss.on('connection', (ws) => {
|
||||||
// check if recipient exists and is connected
|
// check if recipient exists and is connected
|
||||||
if (recipientWs && recipientWs.readyState === WebSocket.OPEN) {
|
if (recipientWs && recipientWs.readyState === WebSocket.OPEN) {
|
||||||
|
|
||||||
|
const timestamp = new Date().toISOString();
|
||||||
|
|
||||||
// The recipient is connected. Forward the message.
|
// The recipient is connected. Forward the message.
|
||||||
const forwardMessage = {
|
const forwardMessage = {
|
||||||
type: MessageType.receive_hl7v2,
|
type: MessageType.receive_hl7v2,
|
||||||
payload: {
|
payload: {
|
||||||
message: message,
|
message: message,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: timestamp,
|
||||||
},
|
},
|
||||||
} as Message;
|
} as Message;
|
||||||
recipientWs.send(JSON.stringify(forwardMessage));
|
recipientWs.send(JSON.stringify(forwardMessage));
|
||||||
console.log(`Forwarded message to ${recipientId}`);
|
console.log(`Forwarded message to ${recipientId}`);
|
||||||
|
|
||||||
|
const ackMessage = {
|
||||||
|
type: MessageType.delivery_success,
|
||||||
|
payload: {
|
||||||
|
message: message,
|
||||||
|
timestamp: timestamp,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
ws.send(JSON.stringify(ackMessage));
|
||||||
|
console.log(`Sent acknowledgment to ${stationId}`);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// The recipient is not connected or not found.
|
// The recipient is not connected or not found.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue