|
33 | 33 | #include "zenoh-pico/protocol/keyexpr.h" |
34 | 34 | #include "zenoh-pico/session/interest.h" |
35 | 35 | #include "zenoh-pico/session/liveliness.h" |
| 36 | +#include "zenoh-pico/session/loopback.h" |
36 | 37 | #include "zenoh-pico/session/query.h" |
37 | 38 | #include "zenoh-pico/session/queryable.h" |
38 | 39 | #include "zenoh-pico/session/resource.h" |
@@ -195,8 +196,15 @@ z_result_t _z_write(_z_session_t *zn, const _z_keyexpr_t *keyexpr, const _z_byte |
195 | 196 | z_priority_t priority, bool is_express, const _z_timestamp_t *timestamp, |
196 | 197 | const _z_bytes_t *attachment, z_reliability_t reliability, const _z_source_info_t *source_info) { |
197 | 198 | z_result_t ret = _Z_RES_OK; |
198 | | - _z_network_message_t msg; |
199 | 199 | _z_qos_t qos = _z_n_qos_make(is_express, cong_ctrl == Z_CONGESTION_CONTROL_BLOCK, priority); |
| 200 | + |
| 201 | + bool handled_locally = _z_session_deliver_push_locally(zn, keyexpr, payload, encoding, kind, qos, timestamp, |
| 202 | + attachment, reliability, source_info); |
| 203 | + if (handled_locally && !_z_session_has_remote_targets(zn)) { |
| 204 | + return _Z_RES_OK; |
| 205 | + } |
| 206 | + |
| 207 | + _z_network_message_t msg; |
200 | 208 | switch (kind) { |
201 | 209 | case Z_SAMPLE_KIND_PUT: |
202 | 210 | _z_n_msg_make_push_put(&msg, keyexpr, payload, encoding, qos, timestamp, attachment, reliability, |
@@ -378,6 +386,12 @@ z_result_t _z_send_reply(const _z_query_t *query, const _z_session_rc_t *zsrc, c |
378 | 386 | } |
379 | 387 | // Build the reply context decorator. This is NOT the final reply. |
380 | 388 | _z_n_qos_t qos = _z_n_qos_make(is_express, cong_ctrl == Z_CONGESTION_CONTROL_BLOCK, priority); |
| 389 | + bool handled_locally = _z_session_deliver_reply_locally(query, zsrc, keyexpr, payload, encoding, kind, qos, |
| 390 | + timestamp, att, source_info); |
| 391 | + if (handled_locally && !_z_session_has_remote_targets(zn)) { |
| 392 | + return _Z_RES_OK; |
| 393 | + } |
| 394 | + |
381 | 395 | _z_zenoh_message_t z_msg; |
382 | 396 | switch (kind) { |
383 | 397 | case Z_SAMPLE_KIND_PUT: |
@@ -408,6 +422,11 @@ z_result_t _z_send_reply_err(const _z_query_t *query, const _z_session_rc_t *zsr |
408 | 422 | // Build the reply context decorator. This is NOT the final reply. |
409 | 423 | _z_n_qos_t qos = _z_n_qos_make(false, true, Z_PRIORITY_DEFAULT); |
410 | 424 | _z_source_info_t source_info = _z_source_info_null(); |
| 425 | + bool handled_locally = _z_session_deliver_reply_err_locally(query, zsrc, payload, encoding, qos); |
| 426 | + if (handled_locally && !_z_session_has_remote_targets(zn)) { |
| 427 | + return _Z_RES_OK; |
| 428 | + } |
| 429 | + |
411 | 430 | _z_zenoh_message_t msg; |
412 | 431 | _z_n_msg_make_reply_err(&msg, &zn->_local_zid, query->_request_id, Z_RELIABILITY_DEFAULT, qos, payload, encoding, |
413 | 432 | &source_info); |
@@ -501,6 +520,13 @@ z_result_t _z_query(_z_session_t *zn, const _z_keyexpr_t *keyexpr, const char *p |
501 | 520 | _z_n_msg_make_query(&z_msg, keyexpr, ¶ms, pq->_id, Z_RELIABILITY_DEFAULT, pq->_consolidation, payload, encoding, |
502 | 521 | timeout_ms, attachment, qos, &source_info); |
503 | 522 |
|
| 523 | + bool handled_locally = _z_session_deliver_query_locally(zn, keyexpr, ¶ms, pq->_consolidation, payload, encoding, |
| 524 | + attachment, &source_info, pq->_id, qos); |
| 525 | + if (handled_locally && !_z_session_has_remote_targets(zn)) { |
| 526 | + _z_trigger_query_reply_final(zn, pq->_id); |
| 527 | + return _Z_RES_OK; |
| 528 | + } |
| 529 | + |
504 | 530 | if (_z_send_n_msg(zn, &z_msg, Z_RELIABILITY_RELIABLE, cong_ctrl, NULL) != _Z_RES_OK) { |
505 | 531 | _z_unregister_pending_query(zn, pq); |
506 | 532 | _Z_ERROR_RETURN(_Z_ERR_TRANSPORT_TX_FAILED); |
|
0 commit comments