Provided access to internal connections where needed, and added multi-line support to send_privmsg(...).

This commit is contained in:
Aaron Weiss 2014-11-03 14:12:23 -05:00
parent 25532d145e
commit 6db71ded01
4 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,6 @@
//! Thread-safe connections on any IrcWriters and IrcReaders
#![experimental]
use std::sync::Mutex;
use std::sync::{Mutex, MutexGuard};
use std::io::{BufferedReader, BufferedWriter, IoResult, TcpStream};
use data::kinds::{IrcWriter, IrcReader};
use data::message::Message;
@ -44,4 +44,10 @@ impl<T, U> Connection<T, U> where T: IrcWriter, U: IrcReader {
pub fn recv(&self) -> IoResult<String> {
self.reader.lock().read_line()
}
/// Acquires the Writer lock
#[experimental]
pub fn writer<'a>(&'a self) -> MutexGuard<'a, T> {
self.writer.lock()
}
}