mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-08-10 18:18:00 +00:00
refactor(server): lower function requirements
Prepare for the next patch, and take "impl FramedWrite" rather than a Framed<W> for the various dispatch methods. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
fa10362106
commit
648f73c995
1 changed files with 16 additions and 32 deletions
|
@ -337,17 +337,14 @@ impl RdpServer {
|
||||||
self.static_channels.get_channel_id_by_type::<T>()
|
self.static_channels.get_channel_id_by_type::<T>()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn dispatch_pdu<W>(
|
async fn dispatch_pdu(
|
||||||
&mut self,
|
&mut self,
|
||||||
action: Action,
|
action: Action,
|
||||||
bytes: bytes::BytesMut,
|
bytes: bytes::BytesMut,
|
||||||
writer: &mut Framed<W>,
|
writer: &mut impl FramedWrite,
|
||||||
io_channel_id: u16,
|
io_channel_id: u16,
|
||||||
user_channel_id: u16,
|
user_channel_id: u16,
|
||||||
) -> Result<RunState>
|
) -> Result<RunState> {
|
||||||
where
|
|
||||||
W: FramedWrite,
|
|
||||||
{
|
|
||||||
match action {
|
match action {
|
||||||
Action::FastPath => {
|
Action::FastPath => {
|
||||||
let input = decode(&bytes)?;
|
let input = decode(&bytes)?;
|
||||||
|
@ -369,18 +366,14 @@ impl RdpServer {
|
||||||
Ok(RunState::Continue)
|
Ok(RunState::Continue)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn dispatch_display_update<W>(
|
async fn dispatch_display_update(
|
||||||
&mut self,
|
|
||||||
update: DisplayUpdate,
|
update: DisplayUpdate,
|
||||||
writer: &mut Framed<W>,
|
writer: &mut impl FramedWrite,
|
||||||
user_channel_id: u16,
|
user_channel_id: u16,
|
||||||
io_channel_id: u16,
|
io_channel_id: u16,
|
||||||
buffer: &mut Vec<u8>,
|
buffer: &mut Vec<u8>,
|
||||||
mut encoder: UpdateEncoder,
|
mut encoder: UpdateEncoder,
|
||||||
) -> Result<(RunState, UpdateEncoder)>
|
) -> Result<(RunState, UpdateEncoder)> {
|
||||||
where
|
|
||||||
W: FramedWrite,
|
|
||||||
{
|
|
||||||
let mut fragmenter = match update {
|
let mut fragmenter = match update {
|
||||||
DisplayUpdate::Bitmap(bitmap) => {
|
DisplayUpdate::Bitmap(bitmap) => {
|
||||||
let (enc, res) = task::spawn_blocking(move || {
|
let (enc, res) = task::spawn_blocking(move || {
|
||||||
|
@ -431,15 +424,12 @@ impl RdpServer {
|
||||||
Ok((RunState::Continue, encoder))
|
Ok((RunState::Continue, encoder))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn dispatch_server_events<W>(
|
async fn dispatch_server_events(
|
||||||
&mut self,
|
&mut self,
|
||||||
events: &mut Vec<ServerEvent>,
|
events: &mut Vec<ServerEvent>,
|
||||||
writer: &mut Framed<W>,
|
writer: &mut impl FramedWrite,
|
||||||
user_channel_id: u16,
|
user_channel_id: u16,
|
||||||
) -> Result<RunState>
|
) -> Result<RunState> {
|
||||||
where
|
|
||||||
W: FramedWrite,
|
|
||||||
{
|
|
||||||
// Avoid wave message queuing up and causing extra delays.
|
// Avoid wave message queuing up and causing extra delays.
|
||||||
// This is a naive solution, better solutions should compute the actual delay, add IO priority, encode audio, use UDP etc.
|
// This is a naive solution, better solutions should compute the actual delay, add IO priority, encode audio, use UDP etc.
|
||||||
// 4 frames should roughly corresponds to hundreds of ms in regular setups.
|
// 4 frames should roughly corresponds to hundreds of ms in regular setups.
|
||||||
|
@ -534,7 +524,7 @@ impl RdpServer {
|
||||||
},
|
},
|
||||||
|
|
||||||
Some(update) = display_updates.next_update() => {
|
Some(update) = display_updates.next_update() => {
|
||||||
(state, encoder) = self.dispatch_display_update(update, writer, user_channel_id, io_channel_id, &mut buffer, encoder).await?;
|
(state, encoder) = Self::dispatch_display_update(update, writer, user_channel_id, io_channel_id, &mut buffer, encoder).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
nevents = self.ev_receiver.recv_many(&mut events, 100) => {
|
nevents = self.ev_receiver.recv_many(&mut events, 100) => {
|
||||||
|
@ -652,16 +642,13 @@ impl RdpServer {
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_input_backlog<W>(
|
async fn handle_input_backlog(
|
||||||
&mut self,
|
&mut self,
|
||||||
writer: &mut Framed<W>,
|
writer: &mut impl FramedWrite,
|
||||||
io_channel_id: u16,
|
io_channel_id: u16,
|
||||||
user_channel_id: u16,
|
user_channel_id: u16,
|
||||||
frames: Vec<Vec<u8>>,
|
frames: Vec<Vec<u8>>,
|
||||||
) -> Result<()>
|
) -> Result<()> {
|
||||||
where
|
|
||||||
W: FramedWrite,
|
|
||||||
{
|
|
||||||
for frame in frames {
|
for frame in frames {
|
||||||
match Action::from_fp_output_header(frame[0]) {
|
match Action::from_fp_output_header(frame[0]) {
|
||||||
Ok(Action::FastPath) => {
|
Ok(Action::FastPath) => {
|
||||||
|
@ -743,16 +730,13 @@ impl RdpServer {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_x224<W>(
|
async fn handle_x224(
|
||||||
&mut self,
|
&mut self,
|
||||||
writer: &mut Framed<W>,
|
writer: &mut impl FramedWrite,
|
||||||
io_channel_id: u16,
|
io_channel_id: u16,
|
||||||
user_channel_id: u16,
|
user_channel_id: u16,
|
||||||
frame: &[u8],
|
frame: &[u8],
|
||||||
) -> Result<bool>
|
) -> Result<bool> {
|
||||||
where
|
|
||||||
W: FramedWrite,
|
|
||||||
{
|
|
||||||
let message = decode::<X224<mcs::McsMessage<'_>>>(frame)?;
|
let message = decode::<X224<mcs::McsMessage<'_>>>(frame)?;
|
||||||
match message.0 {
|
match message.0 {
|
||||||
mcs::McsMessage::SendDataRequest(data) => {
|
mcs::McsMessage::SendDataRequest(data) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue