[][src]Crate active_sse

Activeledger SSE Helper

This crate is a helper crate that handles the setup and configuration of Server Sent Events (Eventsource) calls to Activeledger.


To create a new ActiveSSE instance you need to create a config first. This defines various data needed ActiveSSE to connect to the correct Activeledger API endpoint.

The config types are Activity and Event. These are created simply by calling

let mut config = Config::activity("http://base-url");

let mut config = Config::event("http://base-url");

Once you have created the initial config instance you can pass in the optional data via function calls.

Once configured, use it to create a new instance of ActiveSSE: let sse = ActiveSSE::new(config);

When you are ready, call the subscribe function: let receiver = sse.subscribe();

Then you can listen for activity or events

// Note that this will only return once
println!("{:?}", receiver.recv().unwrap());

This returns a receiever which makes up part of Rust's channel type. You can retrieve messages to it by calling recv

This will only be triggered once, but can be put into a loop to listen for multiple events.

A complete setup might look like this

use active_sse::{Config, ActiveSSE};

let mut config = Config::activity("http://localhost:5260");

config.set_stream_id("Stream id").unwrap();

let listener = ActiveSSE::new(config);
let receiver = listener.subscribe().unwrap();

// Note that this will only return once
println!("{:?}", receiver.recv().unwrap());

Additional Activeledger crates

Adhearing to the Rust mentality of keeping things small we have created other crates that can be used in conjunction with this one to add additional functionality.

These crates are:


Activeledger Developers portal

Activeledger on GitHub

Activeledger on NPM

This SDK on GitHub

Report Issues



Key Error definitions