aboutsummaryrefslogtreecommitdiff
path: root/src/client.rs
diff options
context:
space:
mode:
authorTill Hoeppner2015-06-26 21:51:02 +0200
committerTill Hoeppner2015-06-26 21:51:02 +0200
commitf3122cc55af676c6e1b3f04008e6b455b8b83f5b (patch)
treeafcaf69df2729c05c5ca90f81e53a279f042ac43 /src/client.rs
parentb7bb9b131056c5ffc0552e6c2c16e52781558df7 (diff)
downloadirsc-cows.tar.gz
irsc-cows.tar.xz
irsc-cows.zip
Use SharedClient instead of OwnedClient in Streamscows
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/client.rs b/src/client.rs
index e548a83..2ea2e13 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -212,21 +212,21 @@ pub struct SharedClient {
}
impl SharedClient {
- pub fn messages(&self) -> Stream<(Arc<Mutex<OwnedClient>>, Message)> {
- let cl = self.client.clone();
+ pub fn messages(&self) -> Stream<(SharedClient, Message)> {
+ let cl = SharedClient { client: self.client.clone() };
self.client.lock().unwrap().messages()
.map(move |m| (cl.clone(), m))
}
- /*pub fn events(&self) -> Stream<(Message, Event)> {
- self.client.lock().unwrap().messages().filter_map(|msg| match Command::from_message(&msg) {
- Some(m) => Some((msg, Event::Command(m.clone()))),
+ pub fn events(&self) -> Stream<(SharedClient, Message, Arc<Event<'static>>)> {
+ self.messages().filter_map(|(cl, msg)| match Command::from_message(&msg) {
+ Some(m) => Some((cl, msg, Arc::new(Event::Command(m.clone())))),
None => match Reply::from_message(&msg) {
- Some(r) => Some((msg, Event::Reply(r))),
+ Some(r) => Some((cl, msg, Arc::new(Event::Reply(r)))),
None => None
}
})
- }*/
+ }
// pub fn commands(&self) -> Stream<Command> {
// self.messages().filter_map(|msg| Command::from_message(&msg).map(|c| c.to_static()))