bugfixing
This commit is contained in:
parent
88a2193429
commit
a3fa23b027
@ -369,24 +369,26 @@ fastify.register(async function (fastify) {
|
|||||||
try {
|
try {
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
const fileData = fs.readFileSync(filePath, "utf8");
|
const fileData = fs.readFileSync(filePath, "utf8");
|
||||||
const jsonData = JSON.parse(fileData);
|
const jsonData = JSON?.parse(fileData);
|
||||||
|
|
||||||
// Only send data if conditions are met and data has changed
|
// Only send data if conditions are met and data has changed
|
||||||
if (
|
if (
|
||||||
jsonData?.lp != null &&
|
jsonData?.lp != null &&
|
||||||
|
jsonData?.ap != null &&
|
||||||
|
jsonData?.bp != null &&
|
||||||
jsonData?.t != null &&
|
jsonData?.t != null &&
|
||||||
["Q", "T"].includes(jsonData?.type) &&
|
["Q", "T"].includes(jsonData?.type) &&
|
||||||
connection.socket.readyState === WebSocket.OPEN
|
connection.socket.readyState === WebSocket.OPEN
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// Check if the current data is different from the last sent data
|
// Check if the current data is different from the last sent data
|
||||||
const currentDataSignature = `${jsonData.lp}`;
|
const currentDataSignature = `${jsonData?.lp}`;
|
||||||
const lastSentSignature = lastSentData[symbol];
|
const lastSentSignature = lastSentData[symbol];
|
||||||
|
|
||||||
if (currentDataSignature !== lastSentSignature) {
|
if (currentDataSignature !== lastSentSignature) {
|
||||||
// Collect data to send
|
// Collect data to send
|
||||||
dataToSend.push({
|
dataToSend.push({
|
||||||
symbol, // Include the ticker symbol in the sent data
|
symbol, // Include the ticker symbol in the sent data
|
||||||
lp: jsonData.lp,
|
ap: jsonData?.ap,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the last sent data for this ticker
|
// Update the last sent data for this ticker
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user