Skip to content

Commit

Permalink
add subscriptions and example
Browse files Browse the repository at this point in the history
  • Loading branch information
mycognosist committed Feb 21, 2024
1 parent 4d4cb70 commit cd42725
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions solar_client/examples/subscriptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use anyhow::Result;
use solar_client::{Client, SolarClient};

const SERVER_ADDR: &str = "http://127.0.0.1:3030";
const PUB_KEY: &str = "@HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519";

#[tokio::main]
async fn main() -> Result<()> {
let client = Client::new(SERVER_ADDR.to_owned())?;

let subscriptions = client.subscriptions(PUB_KEY).await?;
println!("{:#?}", subscriptions);
// [
// "falconry",
// "solarfest",
// "compendiumofmadscience",
// "inktober2018",
// "butt-summaries",
// "squatchcam",
// ...
// "arduino",
// "savingspools",
// "meditation",
// ]

Ok(())
}
2 changes: 2 additions & 0 deletions solar_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pub trait SolarClient {

async fn subscribers(&self, channel: &str) -> Vec<String>;

async fn subscriptions(&self, pub_key: &str) -> Vec<String>;

async fn whoami(&self) -> String;
}

Expand Down

0 comments on commit cd42725

Please sign in to comment.