بلاگ
Ethereum: Store console.log result into array every 3 second
I can prove to you with an example Arctic showing Tywew Thoming JavaScript, Hytml and CSS.
MATTERNEUM: Store the console journal results board every 3 seconds *
In Womile we will use node.js orour side emersverse and create Appilt Appol to precipitate Bitcoins prices with bromine. We will be Holy Websocket to drop the customer 3 Secods.
zerver side (no.js)
*
Sagging
Const Exst XPPRSS;
Const App Words Exprest ();
Const Websocket in Requre (WS ‘;
Const in N w new websocket.zerver (port: 808 |);
App.Get (S/BTC/Price ‘, (Req, Arkes)
Constite dw.
Prices Const
Socket.on (“Message”, (Ameat)
IF (Json.parne (data). Symbol Syes
Prices.
Console.lost Price:
/ Ropa Last price for the customer
Sockelt.stend (Json.strysty (symbol: “Bitc”, latest price: prices [Pris [prices – 1]);
E ee
Numbers;
Socket.son (” PLOLOS, ()
WS.CLOLO ();
Numbers;
Numbers;
App. Listen (8080, ().
Console.Log (“8080 Little Server);
Numbers;
.
Customer website (HTML and JavaScript)
*
Cretehtml Street
#Cena-Container {
Fonts: 24PH;
Folgh: Bold;
Marin-Bottom: 20ph;
E ee
SYLE>
ead>
script> o.
New Websocket Socket (WSSS:/Apiince.
Document
Let prices be;
Socket.onsasage NY (Thev Untod)
If (json.passe..symbol escjecing shobtc ‘)
Prices.
Console.lost Price:
E ee
۳ ۳;
Document.Gelet (“Price-Cantinininer”). Innerxt x xpolictoboin price: 1 USD];
Numbers;
Socket.onclolos AIDS
Document.Goletuth (Price-Cantinininer ‘). Innetext X “Prices Avalogle”;
۳ ۳;
script> o.
Oborg>
html>
.
- We create the XPPPS.JS server that lit the WebSocket 8080 and ACedPTS connections.
- And after receiving it analyzes JSON data and stores the price in the board
- At Ethon Incoming, we check if the IF’BTC ‘symbol. IFSO, we analyze the data and God a new price to the end of the board up.
- We will also provide the last price for consals for debugging.
- The WebSocket connection closes, we update the Meu Thisage update in the news that it is a towna.
To refresh time for pages, you are a price, straight to webparge rppproge about clicpading on Btton Belooner “prices”. Server Autotonttor Refreshes and moves prices to Clint.