Skip to content

Instantly share code, notes, and snippets.

@arellano-gustavo
Last active December 13, 2021 05:48
Show Gist options
  • Save arellano-gustavo/25d8e6569c64c9c0d7d3ba6cf7668a9a to your computer and use it in GitHub Desktop.
Save arellano-gustavo/25d8e6569c64c9c0d7d3ba6cf7668a9a to your computer and use it in GitHub Desktop.
Un cliente del websocket de Binance
<!DOCTYPE html>
<html>
<head>
<title>Prueba de un cliente de un websocket</title>
<script type="text/javascript">
var webSocket = new WebSocket('wss://fstream.binance.com/ws/btcusdt@trade');
webSocket.onerror = function(event) {
alert(event.data);
};
webSocket.onopen = function(event) {
document.getElementById('messages').innerHTML = 'New Connection established';
};
webSocket.onmessage = function(event) {
document.getElementById('messages').innerHTML = event.data;
};
</script>
<style type="text/css">
#messages {
height: 60px;
width: 980px;
border: 1px solid #ddd;
background: #f1f1f1;
overflow-y: scroll;
}
</style>
</head>
<body>
<h1>Super Gus !!!</h1>
<div id="messages"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment