-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: abstract reply and push functions
- Loading branch information
1 parent
5838832
commit 8a5ee92
Showing
5 changed files
with
141 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Copyright (c) 2022 ZettaScale Technology | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// | ||
// Contributors: | ||
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
#include <stdint.h> | ||
|
||
#include "zenoh-pico/net/session.h" | ||
#include "zenoh-pico/protocol/core.h" | ||
#include "zenoh-pico/protocol/definitions/message.h" | ||
|
||
#ifndef ZENOH_PICO_SESSION_PUSH_H | ||
#define ZENOH_PICO_SESSION_PUSH_H | ||
|
||
int8_t _z_trigger_push(_z_session_t *zn, _z_n_msg_push_t *push) ; | ||
|
||
#endif /* ZENOH_PICO_SESSION_PUSH_H */ |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// Copyright (c) 2022 ZettaScale Technology | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// | ||
// Contributors: | ||
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
#include <stdint.h> | ||
|
||
#include "zenoh-pico/net/session.h" | ||
#include "zenoh-pico/protocol/core.h" | ||
#include "zenoh-pico/protocol/definitions/message.h" | ||
#include "zenoh-pico/protocol/definitions/network.h" | ||
|
||
#ifndef ZENOH_PICO_SESSION_REPLY_H | ||
#define ZENOH_PICO_SESSION_REPLY_H | ||
|
||
int8_t _z_trigger_reply_partial(_z_session_t *zn, _z_zint_t id, _z_keyexpr_t key, _z_msg_reply_t *reply); | ||
|
||
int8_t _z_trigger_reply_final(_z_session_t *zn, _z_n_msg_response_final_t *final); | ||
|
||
#endif /* ZENOH_PICO_SESSION_REPLY_H */ |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Copyright (c) 2022 ZettaScale Technology | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// | ||
// Contributors: | ||
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
#include "zenoh-pico/session/push.h" | ||
|
||
#include "zenoh-pico/api/constants.h" | ||
#include "zenoh-pico/api/primitives.h" | ||
#include "zenoh-pico/collections/bytes.h" | ||
#include "zenoh-pico/config.h" | ||
#include "zenoh-pico/session/subscription.h" | ||
#include "zenoh-pico/utils/logging.h" | ||
|
||
int8_t _z_trigger_push(_z_session_t *zn, _z_n_msg_push_t *push) { | ||
int8_t ret = _Z_RES_OK; | ||
|
||
// TODO check body to know where to dispatch | ||
_z_bytes_t payload = push->_body._is_put ? push->_body._body._put._payload : _z_bytes_empty(); | ||
_z_encoding_t encoding = push->_body._is_put ? push->_body._body._put._encoding : z_encoding_default(); | ||
int kind = push->_body._is_put ? Z_SAMPLE_KIND_PUT : Z_SAMPLE_KIND_DELETE; | ||
|
||
ret = _z_trigger_subscriptions(zn, push->_key, payload, encoding, kind, push->_timestamp); | ||
|
||
return ret; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Copyright (c) 2022 ZettaScale Technology | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// | ||
// Contributors: | ||
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
#include "zenoh-pico/session/reply.h" | ||
|
||
#include "zenoh-pico/api/constants.h" | ||
#include "zenoh-pico/config.h" | ||
#include "zenoh-pico/session/query.h" | ||
#include "zenoh-pico/utils/logging.h" | ||
|
||
int8_t _z_trigger_reply_partial(_z_session_t *zn, _z_zint_t id, _z_keyexpr_t key, _z_msg_reply_t *reply) { | ||
int8_t ret = _Z_RES_OK; | ||
|
||
// TODO check id to know where to dispatch | ||
|
||
#if Z_FEATURE_QUERY == 1 | ||
ret = _z_trigger_query_reply_partial(zn, id, key, reply->_value.payload, reply->_value.encoding, Z_SAMPLE_KIND_PUT, | ||
reply->_timestamp); | ||
#endif | ||
return ret; | ||
} | ||
|
||
int8_t _z_trigger_reply_final(_z_session_t *zn, _z_n_msg_response_final_t *final) { | ||
int8_t ret = _Z_RES_OK; | ||
|
||
// TODO check id to know where to dispatch | ||
_z_zint_t id = final->_request_id; | ||
|
||
#if Z_FEATURE_QUERY == 1 | ||
_z_trigger_query_reply_final(zn, id); | ||
#endif | ||
return ret; | ||
} |
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