-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: webrtc rpc not working if sender and receiver is created after rpc arrivered #200
fix: webrtc rpc not working if sender and receiver is created after rpc arrivered #200
Conversation
Important Auto Review SkippedDraft detected. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThe update introduces a new module Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (3)
- transports/webrtc/src/transport.rs (1 hunks)
- transports/webrtc/src/transport/internal.rs (8 hunks)
- transports/webrtc/src/transport/rpc_wait_queue.rs (1 hunks)
Additional comments: 11
transports/webrtc/src/transport/rpc_wait_queue.rs (3)
- 3-5: The
RpcWaitQueue
struct is well-defined with a clear purpose, utilizing aHashMap
to queue RPC events by track.- 7-11: The implementation of the
Default
trait forRpcWaitQueue
is correct and idiomatic, ensuring an emptyHashMap
is initialized for new instances.- 22-24: The
take
method correctly retrieves and removes the vector of events for a given track, returning an empty vector if the track does not exist.transports/webrtc/src/transport.rs (1)
- 34-34: The addition of the
rpc_wait_queue
module is correctly implemented, ensuring the new functionality is accessible within the transport module.transports/webrtc/src/transport/internal.rs (7)
- 30-30: The import of
RpcWaitQueue
is correctly added to support the new functionality withinTransportWebrtcInternal
.- 76-78: The addition of
local_wait_rpc
andremote_wait_rpc
fields to theTransportWebrtcInternal
struct is correctly implemented, aligning with the PR objectives to handle RPC events for tracks that are not yet added.- 101-102: Initialization of
local_wait_rpc
andremote_wait_rpc
withDefault::default()
is correct, ensuring these fields are properly initialized when a new instance ofTransportWebrtcInternal
is created.- 250-252: The logic to queue RPC events for local tracks not yet added is correctly implemented. This ensures that RPC events are not lost and can be processed once the track is available.
- 262-264: Similarly, the logic to queue RPC events for remote tracks not yet added is correctly implemented, ensuring that these events are handled appropriately once the track is available.
- 299-307: The process of handling queued RPC events for remote tracks upon their addition is correctly implemented, ensuring that any queued events are processed in the correct order.
- 319-328: The handling of queued RPC events for local tracks upon their addition is correctly implemented, ensuring that any queued events are processed appropriately.
pub fn put(&mut self, track: &str, e: E) { | ||
if let Some(track) = self.tracks.get_mut(track) { | ||
track.push(e); | ||
} else { | ||
self.tracks.insert(track.to_string(), vec![e]); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The put
method correctly handles both existing and new tracks, ensuring that RPC events are queued appropriately. However, consider using entry
API for a more concise implementation.
self.tracks.entry(track.to_string()).or_insert_with(Vec::new).push(e);
Summary by CodeRabbit