aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorGravatar lancebord 2026-03-09 13:47:23 -0400
committerGravatar lancebord 2026-03-09 13:47:23 -0400
commit5b0e9b8a50c337796963c04aabbe23ae4d4bf922 (patch)
tree9e1c88b0394b4ff728e1eea469c11045e62a89d1 /src/client
parentoff by one fix for some word wrapping (diff)
initial move to async instead of polling
Diffstat (limited to '')
-rw-r--r--src/client/mod.rs51
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));
- }
- }
- }
-}