diff options
| author | 2026-03-09 13:49:20 -0400 | |
|---|---|---|
| committer | 2026-03-09 13:49:20 -0400 | |
| commit | 1f10c5ffe6461946d9ada5d4bc174dcef4630047 (patch) | |
| tree | ada37580f6e1fd1d77fe83b0d9e1b9700df637b1 /src/client/mod.rs | |
| parent | add scroll and scroll bar indicator to members list (diff) | |
| parent | initial move to async instead of polling (diff) | |
Merge pull request #1 from lancebord/async-rework
initial move to async instead of polling
Diffstat (limited to 'src/client/mod.rs')
| -rw-r--r-- | src/client/mod.rs | 51 |
1 files changed, 3 insertions, 48 deletions
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<Event> { - 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)); - } - } - } -} |
