RircdState::run()

This commit is contained in:
some body 2021-09-16 16:05:36 -05:00
parent 747f4c759e
commit 62d3493447
3 changed files with 25 additions and 12 deletions

View File

@ -1,16 +1,16 @@
use tokio::sync::oneshot;
use eyre::Result;
enum InternalEvent {
pub enum InternalEvent {
}
enum EventKind {
pub enum EventKind {
Message,
Internal(InternalEvent),
}
pub struct Event {
kind: EventKind,
result_channel: oneshot::Receiver<Result<()>>,
pub kind: EventKind,
pub result_receiver: oneshot::Receiver<Result<()>>,
}

View File

@ -3,7 +3,7 @@ use async_trait::async_trait;
use tokio::sync::{mpsc,oneshot};
use std::sync::Arc;
use eyre::Result;
use crate::event::Event;
use crate::event::{EventKind,Event};
pub struct IrcEndpoint {
}
@ -21,5 +21,12 @@ impl Endpoint for IrcEndpoint {
async fn listen(self: Arc<Self>, success_status_send: oneshot::Sender<Result<()>>,
event_receiver: mpsc::Sender<Event>) {
success_status_send.send(Ok(()));
let (s,r) = oneshot::channel();
event_receiver.send(
Event {
kind: EventKind::Message,
result_receiver: r,
}).await;
}
}

View File

@ -5,7 +5,7 @@ use std::time::Instant;
use std::sync::Arc;
use tokio::sync::oneshot;
use tokio::sync::mpsc;
use crate::event::Event;
use crate::event::{EventKind,Event};
use crate::endpoint::Endpoint;
use crate::irc_endpoint::IrcEndpoint;
@ -68,12 +68,18 @@ impl RircdState {
//> who needs a daemon that does nothing and where nothing can be configured to be done
tokio::select! {
event = event_receiver.recv() => {
match event {
_ => {},
};
},
loop {
println!("received event");
tokio::select! {
event = event_receiver.recv() => {
//TODO don't unwrap() I guess
match event.unwrap().kind {
EventKind::Internal(ev) => {},
EventKind::Message => {},
_ => {},
};
},
};
}
Ok(())