<html><head><title>SpectrumWebSockets</title><script>letsocket=newWebSocket("wss://testnet.telos.eostribe.io/streaming");varactionsList=["transfer","buyram"];varmessageBody={"apikey":"test-api-key","event":"subscribe","type":"get_actions","data":{"account":"eosio"}};socket.onopen=function(e){console.log("[open] Connection established");console.log("Sending to server: "+JSON.stringify(messageBody));socket.send(JSON.stringify(messageBody));};socket.onmessage=function(event){html_log("[message] Data received from server: "+event.data);};socket.onclose=function(event){if(event.wasClean){html_log("[close] Connection closed cleanly, code=${event.code} reason=${event.reason}");}else{html_log("[close] Connection died");}};socket.onerror=function(error){html_log("[error] ${error.message}");};functionhtml_log(data){vardivLog=document.getElementById("log");divLog.innerHTML+="<p>"+data+"</p>";}</script></head><body><h2>SpectrumWebSocketsTest:GetActions</h2><divid="log"></div></body>
Sample HTML/JS Client code for Get Blocks:
<html><head><title>SpectrumWebSockets</title><script>letsocket=newWebSocket("wss://testnet.telos.eostribe.io/streaming");varmessageBody={"apikey":"test-api-key","event":"subscribe","type":"get_blocks"};socket.onopen=function(e){html_log("[open] Connection established");html_log("[subscribe] sending message to server");socket.send(JSON.stringify(messageBody));};socket.onmessage=function(event){html_log("[message] Data received from server: "+event.data);};socket.onclose=function(event){if(event.wasClean){html_log("[close] Connection closed cleanly, code=${event.code} reason=${event.reason}");}else{html_log("[close] Connection died");}};socket.onerror=function(error){html_log("[error] ${error.message}");};functionhtml_log(data){vardivLog=document.getElementById("log");divLog.innerHTML+="<p>"+data+"</p>";}</script></head><body><h2>SpectrumWebSocketsTest:GetBlocks</h2><divid="log"></div></body>
Sample HTML/JS Client code for Get Transaction:
<html><head><title>SpectrumWebSockets</title><script>letsocket=newWebSocket("wss://testnet.telos.eostribe.io/streaming");varmessageBody={"apikey":"test-api-key","event":"subscribe","type":"get_transaction","data":{"account":"eosio"}};socket.onopen=function(e){console.log("[open] Connection established");console.log("Sending to server: "+JSON.stringify(messageBody));socket.send(JSON.stringify(messageBody));};socket.onmessage=function(event){html_log("[message] Data received from server: "+event.data);};socket.onclose=function(event){if(event.wasClean){html_log("[close] Connection closed cleanly, code=${event.code} reason=${event.reason}");}else{html_log("[close] Connection died");}};socket.onerror=function(error){html_log("[error] ${error.message}");};functionhtml_log(data){vardivLog=document.getElementById("log");divLog.innerHTML+="<p>"+data+"</p>";}</script></head><body><h2>SpectrumWebSocketsTest:GetTransactions</h2><divid="log"></div></body>