https://github.com/treethought/hydra-relay
https://github.com/treethought/hydra-relay
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/treethought/hydra-relay
- Owner: treethought
- License: bsd-2-clause
- Created: 2022-04-07T00:09:22.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-07T02:49:23.000Z (about 4 years ago)
- Last Synced: 2025-02-06T12:48:25.200Z (over 1 year ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hydra-relay
A simple websocket server for relaying messages to hydra from non-hydra peers.
This was primarily created to send code to be evaluated within hydra from
neovim
Currently, this is just a simple websocket server that forwards messages to all
connected clients. Taken almost directly from gorilla websocket library's
[example](https://github.com/gorilla/websocket/tree/master/examples/chat).
## Usage
Start the relay server, passing the port to listen on (default 8088).
```
hydra-relay --port 8088
```
Open an instance of hydra, and paste the following:
```
// replace with your relay address
const socket = new WebSocket('ws://localhost:8088/ws');
// Connection opened
socket.addEventListener('open', function (event) {
socket.send('greetings from hydra');
});
function evalRelay(block) {
try {
console.log(eval(block))
} catch (err) {
console.log("error in relay message eval")
socket.send(JSON.stringify(err.message))
}
}
socket.addEventListener('message', function (event) {
console.log(event.data);
evalRelay(event.data);
});
```
Then send blocks of javascript to your relay to have them evaluated in hydra via
any websocket client.