Start of a consumer example

This commit is contained in:
Tony Garnock-Jones 2020-05-11 22:02:56 +02:00
parent a786f4b79b
commit 8dbbfd922a
1 changed files with 12 additions and 0 deletions

12
examples/consumer.rs Normal file
View File

@ -0,0 +1,12 @@
use syndicate::{packets, value::Value};
use tokio::net::TcpStream;
use tokio_util::codec::Framed;
use futures::SinkExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut frames = Framed::new(TcpStream::connect("127.0.0.1:8001").await?,
packets::Codec::<packets::Out, packets::In>::standard());
frames.send(packets::In::Connect(Value::from("producer-consumer-example").wrap())).await?;
Ok(())
}