Open IsrarullahZaheer opened 6 months ago
Dear Mr. @Bassinator the code space is not working because the provided space is fulfil, I am working on this task on local machine and I will update the repo manually. Thanks
Dear Mr. @Bassinator Dear Mr. @JoschaGreuel
After lots of try I couldn't find a good solution for it. If you have any good idea how can we achieve the goal.
I tried with the array but I couldn't achieve the goal.
Hello, I do not have very limited time, but took a short look in the code. So it is not sure if this works, but my idea would be:
Here:
this.client.on("message", (topic, message) => { // Store the latest message for the topic this.latestMessages[topic] = message.toString(); })
change this.latestMessages[topcic] from a simple string to a FIFO queue of strings.
You could implement the queue yourself (https://www.geeksforgeeks.org/implementation-queue-javascript/)
Evt. you can also use this (https://www.npmjs.com/package/queue-fifo)
new codeblock would then be:
this.client.on("message", (topic, message) => {
// Store the latest message for the topic
this.latestMessages[topic].enqueue(message.toString());
})
The coldeblock to implement the hat block would then be changed from:
newMessage({topic}){ return this.latestMessages[topic] || "" }
to
newMessage({topic}){ return this.latestMessages[topic].dequeue() || ""
}
kind regards,
Bastian
Dear Mr. @Bassinator, Thanks for a valuable comments, I will try it and let you know today.
Dear Mr. @Bassinator, I tried both solutions (npm package (queue-fifo)) and I implemented the queue myself both solutions are not working.
the problem is:
Cannot read properties of undefined (reading 'dequeue')
Cannot read properties of undefined (reading 'enqueue')
but it's defined. I will continue working on this task.
you can continue with testing other tasks in the review this is something we can do by downloading the index file again at the end.
NOTE: When you are downloading index file from the repo in (rasbpi) system, make sure you have access to the repo othewise the empty file will download.
Implement the queue structure, Checked the code with Mr. Faisal and will continue working tomorrow
This task is done, I have implemented as queue structure if I have received Hallo 1 Hallo 2 Danke
output will be in the same order
Hallo 1 Hallo 2 Danke
in the screenshots it's showing only Danke but it executed Hallo1 and Hallo 2 before
If a new message is received, this message needs to be accessible from the started code thread within scratch, we should not lose the message.
for example: User A: send three messages in order like: "Hallo 1", "Hallo 2", "Hallo 3" User B: should receive all three messages in the same order: "Hallo 1", "Hallo 2", "Hallo 3"