mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-14 23:19:07 -05:00
track subscriptions in proto
This commit is contained in:
parent
433bb0f130
commit
03a46e20b0
11
src/proto.rs
11
src/proto.rs
|
@ -3,20 +3,23 @@ use crate::error::{Error, Result};
|
||||||
use crate::event::Event;
|
use crate::event::Event;
|
||||||
use crate::subscription::Subscription;
|
use crate::subscription::Subscription;
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
|
use std::collections::HashMap;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
// A protocol handler/helper. Use one per client.
|
// A protocol handler/helper. Use one per client.
|
||||||
pub struct Proto {
|
pub struct Proto {
|
||||||
client_id: Uuid,
|
client_id: Uuid,
|
||||||
// current set of subscriptions
|
// current set of subscriptions
|
||||||
subscriptions: Vec<Subscription>,
|
subscriptions: HashMap<String, Subscription>,
|
||||||
|
max_subs: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Proto {
|
impl Proto {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let p = Proto {
|
let p = Proto {
|
||||||
client_id: Uuid::new_v4(),
|
client_id: Uuid::new_v4(),
|
||||||
subscriptions: Vec::new(),
|
subscriptions: HashMap::new(),
|
||||||
|
max_subs: 128,
|
||||||
};
|
};
|
||||||
debug!("New client: {:?}", p.client_id);
|
debug!("New client: {:?}", p.client_id);
|
||||||
p
|
p
|
||||||
|
@ -31,11 +34,11 @@ impl Proto {
|
||||||
info!("Parse result: {:?}", parse_type(cmd));
|
info!("Parse result: {:?}", parse_type(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subscribe(s: Subscription) {
|
pub fn subscribe(&mut self, s: Subscription) {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unsubscribe(c: Close) {
|
pub fn unsubscribe(&mut self, c: Close) {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user