Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Veritius committed Jul 5, 2024
1 parent e6c8999 commit c57c6af
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
38 changes: 38 additions & 0 deletions quic/src/connections/codes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use std::fmt::Display;

#[derive(Debug)]
pub(super) enum ResetCode {
Unspecified,
}

impl From<u32> for ResetCode {
fn from(value: u32) -> Self {
match value {
0 => Self::Unspecified,

_ => Self::Unspecified,
}
}
}

impl From<ResetCode> for u32 {
fn from(value: ResetCode) -> Self {
match value {
ResetCode::Unspecified => 0,
}
}
}

impl From<ResetCode> for quinn_proto::VarInt {
fn from(value: ResetCode) -> Self {
quinn_proto::VarInt::from_u32(value.into())
}
}

impl Display for ResetCode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
ResetCode::Unspecified => "unspecified or unknown",
})
}
}
1 change: 1 addition & 0 deletions quic/src/connections/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod codes;
mod systems;

pub(crate) use systems::*;
Expand Down
15 changes: 13 additions & 2 deletions quic/src/connections/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{sync::Mutex, time::Instant};
use bevy::{prelude::*, utils::HashMap};
use bevy_stardust::{connections::{PeerAddress, PeerRtt}, prelude::*};
use bytes::BytesMut;
use connections::codes::ResetCode;
use datagrams::{Datagram, DatagramDesequencer, DatagramHeader, DatagramPurpose, DatagramSequencer};
use endpoints::perform_transmit;
use quinn_proto::{Connection, Dir, Event as AppEvent, SendDatagramError, StreamEvent, StreamId, VarInt};
Expand Down Expand Up @@ -164,7 +165,12 @@ pub(crate) fn connection_event_handler_system(
senders.remove(&id);
},

(streams::StreamWriteOutcome::Error(_), _) => todo!(),
(streams::StreamWriteOutcome::Error(_), _) => {
trace!("Stream reset due to error: ");
let _ = stream.reset(ResetCode::Unspecified.into());
senders.remove(&id);
},

_ => {},
}
},
Expand All @@ -173,7 +179,12 @@ pub(crate) fn connection_event_handler_system(
readers.remove(&id);
},

StreamEvent::Stopped { id, error_code: _ } => todo!(),
StreamEvent::Stopped { id, error_code } => {
let code: ResetCode = (error_code.into_inner() as u32).into();
trace!("Remote peer stopped stream: {code}");

todo!()
},

// We don't care about this
StreamEvent::Available { dir: _ } => {},
Expand Down

0 comments on commit c57c6af

Please sign in to comment.