From 03a46e20b0a0b5fda6d6550f598c38e7fed50c71 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Wed, 24 Nov 2021 15:28:15 -0600 Subject: [PATCH] track subscriptions in proto --- src/proto.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/proto.rs b/src/proto.rs index fa2230a..0931a35 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -3,20 +3,23 @@ use crate::error::{Error, Result}; use crate::event::Event; use crate::subscription::Subscription; use log::{debug, info}; +use std::collections::HashMap; use uuid::Uuid; // A protocol handler/helper. Use one per client. pub struct Proto { client_id: Uuid, // current set of subscriptions - subscriptions: Vec, + subscriptions: HashMap, + max_subs: usize, } impl Proto { pub fn new() -> Self { let p = Proto { client_id: Uuid::new_v4(), - subscriptions: Vec::new(), + subscriptions: HashMap::new(), + max_subs: 128, }; debug!("New client: {:?}", p.client_id); p @@ -31,11 +34,11 @@ impl Proto { info!("Parse result: {:?}", parse_type(cmd)); } - pub fn subscribe(s: Subscription) { + pub fn subscribe(&mut self, s: Subscription) { unimplemented!(); } - pub fn unsubscribe(c: Close) { + pub fn unsubscribe(&mut self, c: Close) { unimplemented!(); } }