RircdState::run()
This commit is contained in:
parent
747f4c759e
commit
62d3493447
|
@ -1,16 +1,16 @@
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
|
|
||||||
enum InternalEvent {
|
pub enum InternalEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum EventKind {
|
pub enum EventKind {
|
||||||
Message,
|
Message,
|
||||||
Internal(InternalEvent),
|
Internal(InternalEvent),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub struct Event {
|
pub struct Event {
|
||||||
kind: EventKind,
|
pub kind: EventKind,
|
||||||
result_channel: oneshot::Receiver<Result<()>>,
|
pub result_receiver: oneshot::Receiver<Result<()>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use async_trait::async_trait;
|
||||||
use tokio::sync::{mpsc,oneshot};
|
use tokio::sync::{mpsc,oneshot};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
use crate::event::Event;
|
use crate::event::{EventKind,Event};
|
||||||
|
|
||||||
pub struct IrcEndpoint {
|
pub struct IrcEndpoint {
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,12 @@ impl Endpoint for IrcEndpoint {
|
||||||
async fn listen(self: Arc<Self>, success_status_send: oneshot::Sender<Result<()>>,
|
async fn listen(self: Arc<Self>, success_status_send: oneshot::Sender<Result<()>>,
|
||||||
event_receiver: mpsc::Sender<Event>) {
|
event_receiver: mpsc::Sender<Event>) {
|
||||||
success_status_send.send(Ok(()));
|
success_status_send.send(Ok(()));
|
||||||
|
|
||||||
|
let (s,r) = oneshot::channel();
|
||||||
|
event_receiver.send(
|
||||||
|
Event {
|
||||||
|
kind: EventKind::Message,
|
||||||
|
result_receiver: r,
|
||||||
|
}).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
src/state.rs
20
src/state.rs
|
@ -5,7 +5,7 @@ use std::time::Instant;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use crate::event::Event;
|
use crate::event::{EventKind,Event};
|
||||||
|
|
||||||
use crate::endpoint::Endpoint;
|
use crate::endpoint::Endpoint;
|
||||||
use crate::irc_endpoint::IrcEndpoint;
|
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
|
//> who needs a daemon that does nothing and where nothing can be configured to be done
|
||||||
|
|
||||||
|
|
||||||
tokio::select! {
|
loop {
|
||||||
event = event_receiver.recv() => {
|
println!("received event");
|
||||||
match event {
|
tokio::select! {
|
||||||
_ => {},
|
event = event_receiver.recv() => {
|
||||||
};
|
//TODO don't unwrap() I guess
|
||||||
},
|
match event.unwrap().kind {
|
||||||
|
EventKind::Internal(ev) => {},
|
||||||
|
EventKind::Message => {},
|
||||||
|
_ => {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue