Skip to content

Commit

Permalink
feat: remove ke from unicast undecl sub
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Mar 11, 2024
1 parent 20857b3 commit c9dba51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/net/primitives.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ int8_t _z_undeclare_subscriber(_z_subscriber_t *sub) {
return _Z_ERR_ENTITY_UNKNOWN;
}
// Build the declare message to send on the wire
_z_declaration_t declaration = _z_make_undecl_subscriber(sub->_entity_id, &s->in->val._key);
_z_declaration_t declaration;
if (sub->_zn.in->val._tp._type == _Z_TRANSPORT_UNICAST_TYPE) {
declaration = _z_make_undecl_subscriber(sub->_entity_id, NULL);
} else {
declaration = _z_make_undecl_subscriber(sub->_entity_id, &s->in->val._key);
}
_z_network_message_t n_msg = _z_n_msg_make_declare(declaration);
if (_z_send_n_msg(&sub->_zn.in->val, &n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK) != _Z_RES_OK) {
return _Z_ERR_TRANSPORT_TX_FAILED;
Expand Down
8 changes: 6 additions & 2 deletions src/protocol/definitions/declarations.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ _z_declaration_t _z_make_decl_subscriber(_Z_MOVE(_z_keyexpr_t) key, uint32_t id,
._keyexpr = _z_keyexpr_steal(key),
._ext_subinfo = {._pull_mode = pull_mode, ._reliable = reliable}}}};
}

_z_declaration_t _z_make_undecl_subscriber(uint32_t id, _Z_OPTIONAL const _z_keyexpr_t *key) {
return (_z_declaration_t){._tag = _Z_UNDECL_SUBSCRIBER,
._body = {._undecl_subscriber = {._id = id, ._ext_keyexpr = _z_keyexpr_duplicate(*key)}}};
return (_z_declaration_t){
._tag = _Z_UNDECL_SUBSCRIBER,
._body = {._undecl_subscriber = {
._id = id, ._ext_keyexpr = (key == NULL) ? _z_keyexpr_null() : _z_keyexpr_duplicate(*key)}}};
}

_z_declaration_t _z_make_decl_queryable(_Z_MOVE(_z_keyexpr_t) key, uint32_t id, uint32_t distance, uint8_t complete) {
return (_z_declaration_t){
._tag = _Z_DECL_QUERYABLE,
Expand Down

0 comments on commit c9dba51

Please sign in to comment.