-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cd513a
commit b530da2
Showing
7 changed files
with
148 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,11 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
use super::Primitives; | ||
use crate::net::routing::{dispatcher::face::Face, interceptor::IngressIntercept, RoutingContext}; | ||
use crate::net::routing::{ | ||
dispatcher::face::Face, | ||
interceptor::{InterceptTrait, InterceptsChain}, | ||
RoutingContext, | ||
}; | ||
use std::any::Any; | ||
use zenoh_link::Link; | ||
use zenoh_protocol::network::{NetworkBody, NetworkMessage}; | ||
|
@@ -22,14 +26,14 @@ use zenoh_transport::{TransportPeerEventHandler, TransportUnicast}; | |
pub struct DeMux { | ||
face: Face, | ||
pub(crate) transport: Option<TransportUnicast>, | ||
pub(crate) intercept: IngressIntercept, | ||
pub(crate) intercept: InterceptsChain, | ||
} | ||
|
||
impl DeMux { | ||
pub(crate) fn new( | ||
face: Face, | ||
transport: Option<TransportUnicast>, | ||
intercept: IngressIntercept, | ||
intercept: InterceptsChain, | ||
) -> Self { | ||
Self { | ||
face, | ||
|
@@ -41,14 +45,17 @@ impl DeMux { | |
|
||
impl TransportPeerEventHandler for DeMux { | ||
#[inline] | ||
fn handle_message(&self, msg: NetworkMessage) -> ZResult<()> { | ||
let ctx = RoutingContext::with_face(msg, self.face.clone()); | ||
let ctx = match self.intercept.intercept(ctx) { | ||
Some(ctx) => ctx, | ||
None => return Ok(()), | ||
}; | ||
fn handle_message(&self, mut msg: NetworkMessage) -> ZResult<()> { | ||
if !self.intercept.intercepts.is_empty() { | ||
let ctx = RoutingContext::new_in(msg, self.face.clone()); | ||
let ctx = match self.intercept.intercept(ctx) { | ||
Some(ctx) => ctx, | ||
None => return Ok(()), | ||
}; | ||
msg = ctx.msg; | ||
} | ||
|
||
match ctx.msg.body { | ||
match msg.body { | ||
NetworkBody::Push(m) => self.face.send_push(m), | ||
NetworkBody::Declare(m) => self.face.send_declare(m), | ||
NetworkBody::Request(m) => self.face.send_request(m), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.