|
@@ -19,7 +19,9 @@ fn on_connection(
|
|
|
_socket: mpsc::Sender<Request>,
|
|
|
) -> Pin<Box<dyn Future<Output = ()> + Send>> {
|
|
|
println!("Reconnecting to {}", host);
|
|
|
- Box::pin(async move {})
|
|
|
+ Box::pin(async move {
|
|
|
+ let _ = _socket.send(Subscribe::default().into()).await;
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
#[tokio::main]
|
|
@@ -49,15 +51,21 @@ async fn main() {
|
|
|
let db = RocksDb::new("./db").expect("db");
|
|
|
|
|
|
loop {
|
|
|
- if let Some((msg, _relayed_by)) = clients.recv().await {
|
|
|
+ if let Some((msg, relayed_by)) = clients.recv().await {
|
|
|
match msg {
|
|
|
- Event::Response(Response::Event(x)) => {
|
|
|
- let event = x.event;
|
|
|
- db.store(&event).expect("valid");
|
|
|
- }
|
|
|
- Event::Response(Response::EndOfStoredEvents(_)) => {}
|
|
|
+ Event::Response(r) => match *r {
|
|
|
+ Response::Event(x) => {
|
|
|
+ println!("{} => {:?}", relayed_by, x);
|
|
|
+ let event = x.event;
|
|
|
+ db.store(&event).expect("valid");
|
|
|
+ }
|
|
|
+ Response::EndOfStoredEvents(_) => {}
|
|
|
+ msg => {
|
|
|
+ println!("{} {:?}", relayed_by, msg);
|
|
|
+ }
|
|
|
+ },
|
|
|
msg => {
|
|
|
- panic!("{:?}", msg);
|
|
|
+ println!("{} {:?}", relayed_by, msg);
|
|
|
}
|
|
|
}
|
|
|
}
|