From 5b0e9b8a50c337796963c04aabbe23ae4d4bf922 Mon Sep 17 00:00:00 2001 From: lancebord Date: Mon, 9 Mar 2026 13:47:23 -0400 Subject: initial move to async instead of polling --- src/client/mod.rs | 51 +++------------------------------------------------ 1 file changed, 3 insertions(+), 48 deletions(-) (limited to 'src/client/mod.rs') diff --git a/src/client/mod.rs b/src/client/mod.rs index f02f8e5..0199395 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -51,38 +51,9 @@ impl Client { Ok(client) } - /// Send a raw `IrcMessage` to the server. - pub fn send(&self, msg: IrcMessage) { - self.sender.send(msg); - } - - /// Send a PRIVMSG to a channel or user. - pub fn privmsg(&self, target: &str, text: &str) { - self.sender.send(IrcMessage::new( - Command::Privmsg, - vec![target.to_string(), text.to_string()], - )); - } - - /// Join a channel. - pub fn join(&self, channel: &str) { - self.sender - .send(IrcMessage::new(Command::Join, vec![channel.to_string()])); - } - - /// Part a channel. - pub fn part(&self, channel: &str, reason: Option<&str>) { - let mut params = vec![channel.to_string()]; - if let Some(r) = reason { - params.push(r.to_string()); - } - self.sender.send(IrcMessage::new(Command::Part, params)); - } - - /// Change nick. - pub fn nick(&self, new_nick: &str) { - self.sender - .send(IrcMessage::new(Command::Nick, vec![new_nick.to_string()])); + /// Offer a clone of the sender + pub fn sender(&self) -> Sender { + self.sender.clone() } /// Read-only view of current client state. @@ -137,19 +108,3 @@ impl Client { )); } } - -impl Client { - /// Non-blocking version of `next_event`. - /// Returns `Some(event)` if one is immediately available, `None` otherwise. - /// Used by the TUI loop to drain events without blocking the render tick. - pub fn next_event_nowait(&mut self) -> Option { - loop { - let msg = self.inbox.try_recv().ok()?; - let mut events = handle(msg, &mut self.state, &self.sender); - - if !events.is_empty() { - return Some(events.remove(0)); - } - } - } -} -- cgit v1.2.3-59-g8ed1b