Skip to content

Commit 3c97019

Browse files
committed
feat(dvc)!: expose dynamic channel accessors
Add mutable dynamic channel lookup APIs for drdynvc client / server. BREAKING CHANGE: DynamicVirtualChannel::channel_processor_downcast_ref now requires `DvcClientProcessor` instead of `DvcProcessor`. Signed-off-by: uchouT <i@uchout.moe>
1 parent 9046144 commit 3c97019

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

crates/ironrdp-dvc/src/client.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ impl DrdynvcClient {
161161
self.dynamic_channels.get_by_channel_id(channel_id)
162162
}
163163

164+
pub fn get_dvc_by_channel_id_mut(&mut self, channel_id: u32) -> Option<&mut DynamicVirtualChannel> {
165+
self.dynamic_channels.get_by_channel_id_mut(channel_id)
166+
}
167+
164168
fn create_capabilities_response(&mut self, server_version: CapsVersion) -> SvcMessage {
165169
let caps_response = DrdynvcClientPdu::Capabilities(CapabilitiesResponsePdu::new(server_version));
166170
debug!("Send DVC Capabilities Response PDU: {caps_response:?}");

crates/ironrdp-dvc/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,14 @@ impl DynamicVirtualChannel {
138138
self.channel_id
139139
}
140140

141-
pub fn channel_processor_downcast_ref<T: DvcProcessor>(&self) -> Option<&T> {
141+
pub fn channel_processor_downcast_ref<T: DvcClientProcessor>(&self) -> Option<&T> {
142142
self.channel_processor.as_any().downcast_ref()
143143
}
144144

145+
pub fn channel_processor_downcast_mut<T: DvcClientProcessor>(&mut self) -> Option<&mut T> {
146+
self.channel_processor.as_any_mut().downcast_mut()
147+
}
148+
145149
fn start(&mut self, channel_id: DynamicChannelId) -> PduResult<Vec<DvcMessage>> {
146150
let messages = self.channel_processor.start(channel_id)?;
147151
self.channel_id = Some(channel_id);

crates/ironrdp-dvc/src/server.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ impl DrdynvcServer {
186186
.ok_or_else(|| invalid_field_err!("DRDYNVC", "", "invalid channel id"))
187187
}
188188

189+
pub fn dvc_by_id<T: DvcServerProcessor>(&self, id: u32) -> Option<&T> {
190+
self.dynamic_channels
191+
.get(id)
192+
.and_then(|w| w.processor.as_any().downcast_ref())
193+
}
194+
195+
pub fn dvc_by_id_mut<T: DvcServerProcessor>(&mut self, id: u32) -> Option<&mut T> {
196+
self.dynamic_channels
197+
.get_mut(id)
198+
.and_then(|c| c.processor.as_any_mut().downcast_mut())
199+
}
200+
189201
/// Creates a new DVC, returns CreateRequest PDU to send to client.
190202
///
191203
/// # Panics

0 commit comments

Comments
 (0)