forked from Kuska-ssb/solar
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5abd301
commit 0c5cee6
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use anyhow::Result; | ||
use serde_json::json; | ||
use solar_client::{Client, SolarClient}; | ||
|
||
const SERVER_ADDR: &str = "http://127.0.0.1:3030"; | ||
const TEXT: &str = "Testing message publishing via the solar JSON-RPC client"; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let client = Client::new(SERVER_ADDR.to_owned())?; | ||
|
||
// Construct a JSON post. | ||
// | ||
// This can take any shape conforming to | ||
// `kuska_ssb::api::dto::content::TypedMessage`. | ||
// | ||
// Consult the `kuska_ssb` repo for more details: | ||
// https://github.com/Kuska-ssb/ssb | ||
let post = json!({ | ||
"type": "post", | ||
"text": TEXT, | ||
}); | ||
|
||
let msg_ref_and_seq_num = client.publish(post).await?; | ||
println!("{:?}", msg_ref_and_seq_num); | ||
// ("%J0k3hbXE6CjoA2yFpUsy+A1K+GRcTc5Eh6LH7OuzzUE=.sha256", 231) | ||
|
||
// Or destructure the tuple into individual components: | ||
// let (msg_ref, seq_num) = client.publish(post).await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters