mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 10:35:50 +00:00
Beast.WebSocket provides developers with a robust WebSocket implementation built on Boost.Asio with a consistent asynchronous model using a modern C++ approach.
24 lines
466 B
JavaScript
24 lines
466 B
JavaScript
// npm install ws
|
|
// WS_ADDRESS=127.0.0.1:6006 node ripple-websocket.js
|
|
|
|
var WebSocket = require('ws')
|
|
|
|
console.log(process.env.WS_ADDRESS)
|
|
var ws = new WebSocket('ws://'+process.env.WS_ADDRESS)
|
|
|
|
ws.on('error', function(error){
|
|
console.log(error)
|
|
})
|
|
|
|
ws.on('open', function () {
|
|
ws.send(JSON.stringify({
|
|
"id": 1,
|
|
"command": "server_info"
|
|
}))
|
|
})
|
|
|
|
ws.on('message', function(dataString, flags) {
|
|
var data = JSON.parse(dataString)
|
|
console.log(data)
|
|
})
|