Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WebSocket into Emit/Recieve (How to publish a value into Recieve and how to recieve it?)
// I want this function in my rust program to push an entry into the DHT but now sure how to do this under this EMIT method?
let signal_string = "I want this go into the signal entry on my dht";
fn set_to_dht(_signal: String) {
let json = serde_json::json!(
{"id": "signal",
"jsonrpc": "2.0",
"method": "call",
"params": {"instance_id": "test-instance",
"zome": "signal_node",
"function": "receive",
"args": {
"_address": "HcSCIjn77EYm9C6gqsxuisP95WBnw5jf5QCAVAZ5dizvamsfDZSAXi35BVj5bsz",
"_msg": _signal,
connect("ws://localhost:3401", |out| {
move |msg| {
println!("Worked: {:#?}", msg);
// I then want to write some logic in a receiver RUST program to 'listen' and update a variable when the zome emits a change but unsure what that should look like?
// I'm using the WS Crate here but if you have an existing snip that does the same thing with Websocket crate then feel free to replace my function here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment