Untitled
unknown
plain_text
a year ago
7.7 kB
18
Indexable
const net = require('net');
// Define the port and host for the TCP server
const SERVER_HOST = '0.0.0.0'; // Replace with the actual host if needed
const SERVER_PORT = 8888; // Replace with the actual port
const receiptLines = [
"${POS 1} 1 18-Nov-2024 10:00:19 PM 9915 2 Begin Sale: Op #: 2",
"${POS 1} Price Set: PLU (DEPT12) Lotto $1.00",
"${POS 1} Added Item: PLU (DEPT12) Lotto $1.00 Tax Group 99",
"${POS 1} Sub Total: $1.00, Trans Disc: $0.00, Tax: $0.00, Total: $1.00",
"${POS 1} Tender Added: Cash $1.00",
"${POS 1} 1 18-Nov-2024 10:00:22 PM 9915 2 End Sale: Op #: 2",
"${POS 1} 1 18-Nov-2024 10:23:56 PM 9916 2 Begin Sale: Op #: 2",
"${POS 1} Restricted Item Min Buyer Age 21 check, Default Birthdate.",
"${POS 1} Added Item: PLU (088004048532) fireball 50ml $1.99 Tax Group 101",
"${POS 1} Price Set: PLU (DEPT11) Tobacco $2.00",
"${POS 1} Added Item: PLU (DEPT11) Tobacco $2.00 Tax Group 101",
"${POS 1} Sub Total: $3.99, Trans Disc: $0.00, Tax: $0.32, Total: $4.31",
"${POS 1} Tender Added: Debit $4.31",
"${POS 1} TYPE# Debit ACCT# XXXXXXXXXXXX1184 INV# E/D056857 AUTH# 595160",
"${POS 1} 1 18-Nov-2024 10:24:27 PM 9916 2 End Sale: Op #: 2",
"${POS 1} 1 18-Nov-2024 10:44:19 PM 9917 2 Begin Sale: Op #: 2",
"${POS 1} Price Set: PLU (DEPT12) Lotto $1.00",
"${POS 1} Added Item: PLU (DEPT12) Lotto $1.00 Tax Group 99",
"${POS 1} Sub Total: $1.00, Trans Disc: $0.00, Tax: $0.00, Total: $1.00",
"${POS 1} Tender Added: Cash $1.00",
"${POS 1} 1 18-Nov-2024 10:44:21 PM 9917 2 End Sale: Op #: 2",
"${POS 1} 1 18-Nov-2024 11:09:09 PM 9918 2 Begin Sale: Op #: 2",
"${POS 1} Price Set: PLU (DEPT12) Lotto $1.00",
"${POS 1} Added Item: PLU (DEPT12) Lotto $1.00 Tax Group 99",
"${POS 1} Sub Total: $1.00, Trans Disc: $0.00, Tax: $0.00, Total: $1.00",
"${POS 1} Tender Added: Cash $1.00",
"${POS 1} 1 18-Nov-2024 11:09:11 PM 9918 2 End Sale: Op #: 2",
"${POS 1} 1 18-Nov-2024 11:15:39 PM 9919 2 Begin Sale: Op #: 2",
"${POS 1} Price Set: PLU (DEPT12) Lotto $1.00",
"${POS 1} Added Item: PLU (DEPT12) Lotto $1.00 Tax Group 99",
"${POS 1} Sub Total: $1.00, Trans Disc: $0.00, Tax: $0.00, Total: $1.00",
"${POS 1} Tender Added: Cash $1.00",
"${POS 1} 1 18-Nov-2024 11:15:41 PM 9919 2 End Sale: Op #: 2",
"${POS 1} Tender Count - Transaction started.",
"${POS 1} Tender Count - New Count started. Count Type is Final Count. Employee ID 2. TillID: 000000008803",
"${POS 1} Tender Count - New Count Detail Added. Tender Type: Cash. Tender Amount: $0.00. Tender Count: 0. Tender Denomination: 0",
"${POS 1} Tender Count - Count Complete",
"${POS 1} Tender Count - Transaction finished.",
"${POS 1} Register (1) Closed.",
"${POS 1} EOS Sign-off - operator 2",
"${POS 1} Terminal 1 is Open. Business Date: 11/18/24 11:37:10 PM",
"${POS 1} Sign-on - operator 2",
"${POS 1} Sign-on - Assigned Till: 000000008804",
"${POS 1} Tender Count - Transaction started.",
"${POS 1} Tender Count - New Count started. Count Type is Initial Count. Employee ID 2. TillID: 000000008804",
"${POS 1} Tender Count - New Count Detail Added. Tender Type: Cash. Tender Amount: $500.00. Tender Count: 0. Tender Denomination: 0",
"${POS 1} Tender Count - Count Complete",
"${POS 1} Tender Count - Count Complete",
"${POS 1} Tender Count - Transaction finished.",
"${POS 1} 1 19-Nov-2024 12:06:16 AM 9922 2 Begin Sale: Op #: 2",
"${POS 1} Item: PLU (DEPT12) Canceled.",
"${POS 1} Terminal 1 is Open. Business Date: 11/18/24 11:37:10 PM",
"${POS 1} Sign-on - operator 2",
"${POS 1} Sign-on - Assigned Till: 000000008804",
"${POS 1} 1 19-Nov-2024 12:14:51 AM 9923 2 Begin Sale: Op #: 2",
"${POS 1} Price Set: PLU (DEPT12) Lotto $1.00",
"${POS 1} Added Item: PLU (DEPT12) Lotto $1.00 Tax Group 99",
"${POS 1} Sub Total: $1.00, Trans Disc: $0.00, Tax: $0.00, Total: $1.00",
"${POS 1} Tender Added: Cash $1.00",
"${POS 1} 1 19-Nov-2024 12:15:16 AM 9924 2 Begin Sale: Op #: 2",
"${POS 1} Price Set: PLU (DEPT2) Grocery 1 $2.49",
"${POS 1} Added Item: PLU (DEPT2) Grocery 1 $2.49 Tax Group 102",
"${POS 1} Price Set: PLU (DEPT2) Grocery 1 $5.00",
"${POS 1} Added Item: PLU (DEPT2) Grocery 1 $5.00 Tax Group 102",
"${POS 1} Price Set: PLU (DEPT2) Grocery 1 $11.00",
"${POS 1} Added Item: PLU (DEPT2) Grocery 1 $11.00 Tax Group 102",
"${POS 1} Price Set: PLU (DEPT2) Grocery 1 $2.49",
"${POS 1} Added Item: PLU (DEPT2) Grocery 1 $2.49 Tax Group 102",
"${POS 1} Price Set: PLU (DEPT2) Grocery 1 $0.50",
"${POS 1} Added Item: PLU (DEPT2) Grocery 1 $0.50 Tax Group 102",
"${POS 1} Price Set: PLU (DEPT2) Grocery 1 $2.29",
"${POS 1} Added Item: PLU (DEPT2) Grocery 1 $2.29 Tax Group 102",
"${POS 1} Price Set: PLU (DEPT2) Grocery 1 $2.99",
"${POS 1} Added Item: PLU (DEPT2) Grocery 1 $2.99 Tax Group 102",
"${POS 1} Restricted Item Min Buyer Age 21 check, Default Birthdate.",
"${POS 1} Added Item: PLU (026100005752) Newport Regular $9.68 Tax Group 101",
"${POS 1} Price Set: PLU (DEPT11) Tobacco $2.99",
"${POS 1} Added Item: PLU (DEPT11) Tobacco $2.99 Tax Group 101",
"${POS 1} Price Set: PLU (DEPT11) Tobacco $9.99",
"${POS 1} Added Item: PLU (DEPT11) Tobacco $9.99 Tax Group 101",
"${POS 1} Price Set: PLU (DEPT11) Tobacco $6.99",
"${POS 1} Added Item: PLU (DEPT11) Tobacco $6.99 Tax Group 101",
"${POS 1} Price Set: PLU (DEPT6) Beer $3.99",
"${POS 1} Added Item: PLU (DEPT6) Beer $3.99 Tax Group 101",
"${POS 1} Sub Total: $60.40, Trans Disc: $0.00, Tax: $3.49, Total: $63.89",
"${POS 1} Tender Added: Cash $63.89",
"${POS 1} 1 19-Nov-2024 12:16:54 AM 9924 2 End Sale: Op #: 2",
"${POS 1} 1 19-Nov-2024 12:20:19 AM 9925 2 Begin Sale: Op #: 2",
"${POS 1} Price Set: PLU (DEPT12) Lotto $1.00",
"${POS 1} Added Item: PLU (DEPT12) Lotto $1.00 Tax Group 99",
"${POS 1} Sub Total: $1.00, Trans Disc: $0.00, Tax: $0.00, Total: $1.00",
"${POS 1} Tender Added: Cash $1.00",
"${POS 1} 1 19-Nov-2024 12:24:05 AM 9925 2 End Sale: Op #: 2",
"${POS 1} 1 19-Nov-2024 12:38:31 AM 9926 2 Begin Sale: Op #: 2",
"${POS 1} Price Set: PLU (DEPT12) Lotto $1.00",
"${POS 1} Added Item: PLU (DEPT12) Lotto $1.00 Tax Group 99",
"${POS 1} Sub Total: $1.00, Trans Disc: $0.00, Tax: $0.00, Total: $1.00",
"${POS 1} Voided Item: PLU (DEPT12) Lotto -$1.00",
"${POS 1} Status information requested.",
"${POS 1} Price Set: PLU (DEPT30) VAP $7.99",
"${POS 1} Restricted Item Min Buyer Age 21 check, Default Birthdate."
]
// Create the TCP server
const server = net.createServer((socket) => {
console.log('Client connected');
// Function to send lines with a delay between each
let lineIndex = 0;
const sendLine = () => {
if (lineIndex < receiptLines.length) {
socket.write(receiptLines[lineIndex] + '\n');
lineIndex++;
} else {
lineIndex = 0; // Reset the index to start over again
}
// Continue sending lines with a delay of 500ms between lines
setTimeout(sendLine, 500);
};
// Start sending lines as soon as the client connects
sendLine();
// Handle client disconnection
socket.on('end', () => {
console.log('Client disconnected');
});
// Handle errors
socket.on('error', (err) => {
console.error(`Server error: ${err.message}`);
});
});
// Start listening on the specified host and port
server.listen(SERVER_PORT, SERVER_HOST, () => {
console.log(`Server listening on ${SERVER_HOST}:${SERVER_PORT}`);
});Editor is loading...
Leave a Comment