feat: parse subscriptions from websockets

Parses subscription requests (REQ, but not CLOSE).  Performs no
subscription state management yet.
This commit is contained in:
Greg Heartsfield
2021-12-05 17:15:50 -06:00
parent 92e9a5e639
commit e7d0ab1aca
5 changed files with 335 additions and 8 deletions
+10 -3
View File
@@ -72,11 +72,18 @@ async fn nostr_server(
tokio::select! {
proto_next = nostr_stream.next() => {
match proto_next {
Some(Ok(EventMsg(e))) => {
Some(Ok(EventMsg(ec))) => {
// An EventCmd needs to be validated to be converted into an Event
// handle each type of message
let _x : Result<Event> = Result::<Event>::from(e);
let parsed : Result<Event> = Result::<Event>::from(ec);
match parsed {
Ok(_) => {info!("Successfully parsed/validated event")},
Err(_) => {info!("Invalid event ignored")}
}
},
Some(Ok(SubMsg(s))) => {
info!("Sub request from client: {:?}", s);
},
Some(Ok(SubMsg)) => {},
Some(Ok(CloseMsg)) => {},
None => {
info!("stream ended");