-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial prototype is working for GenericSocketBackend TODO: * implement for rest of the sockets * implement outgoing queue for messages according to ZMQ spec Related to #143
- Loading branch information
1 parent
cc5bc5f
commit 830e2da
Showing
12 changed files
with
159 additions
and
37 deletions.
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
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,24 @@ | ||
mod async_helpers; | ||
|
||
use futures::StreamExt; | ||
use std::{error::Error, time::Duration}; | ||
use zeromq::prelude::*; | ||
|
||
#[async_helpers::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
let mut client = zeromq::DealerSocket::new(); | ||
let mut monitor = client.monitor(); | ||
async_helpers::spawn(async move { | ||
while let Some(event) = monitor.next().await { | ||
dbg!(event); | ||
} | ||
}); | ||
|
||
client.connect("tcp://127.0.0.1:5559").await?; | ||
|
||
loop { | ||
let result = client.send("Test message".into()).await; | ||
dbg!(result); | ||
async_helpers::sleep(Duration::from_secs(1)).await; | ||
} | ||
} |
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,17 @@ | ||
mod async_helpers; | ||
|
||
use std::{convert::TryFrom, error::Error}; | ||
use zeromq::{prelude::*, util::PeerIdentity, SocketOptions}; | ||
|
||
#[async_helpers::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
let mut options = SocketOptions::default(); | ||
options.peer_identity(PeerIdentity::try_from(Vec::from("SomeCustomId")).unwrap()); | ||
let mut frontend = zeromq::RouterSocket::with_options(options); | ||
frontend.bind("tcp://127.0.0.1:5559").await?; | ||
|
||
loop { | ||
let message = frontend.recv().await?; | ||
dbg!(message); | ||
} | ||
} |
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
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
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
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
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
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
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
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
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