-
-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These are new functions that replace `NNG_OPT_SUBSCRIBE` and `NNG_OPT_UNSUBSCRIBE`. They are provided here as a transition aid before those options are removed in NNG 2.0.
- Loading branch information
Showing
8 changed files
with
484 additions
and
283 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
= nng_sub_subscribe(3) | ||
// | ||
// Copyright 2024 Staysail Systems, Inc. <[email protected]> | ||
// | ||
// This document is supplied under the terms of the MIT License, a | ||
// copy of which should be located in the distribution where this | ||
// file was obtained (LICENSE.txt). A copy of the license may also be | ||
// found online at https://opensource.org/licenses/MIT. | ||
// | ||
|
||
== NAME | ||
|
||
nng_sub_subscribe - manage SUB subscriptions | ||
|
||
== SYNOPSIS | ||
|
||
[source,c] | ||
---- | ||
#include <nng/nng.h> | ||
#include <nng/protocol/pubsub0/sub.h> | ||
int nng_sub0_socket_subscribe(nng_socket s, const void *buf, size_t sz); | ||
int nng_sub0_socket_unsubscribe(nng_socket s, const void *buf, size_t sz); | ||
int nng_sub0_ctx_subscribe(nng_ctx c, const void *buf, size_t sz); | ||
int nng_sub0_ctx_unsubscribe(nng_ctx c, const void *buf, size_t sz); | ||
---- | ||
|
||
== DESCRIPTION | ||
|
||
These functions are used to subscribe, or unsubscribe, message topics | ||
on either the xref:nng_sub.7.adoc[_sub_] version 0 socket _s_, | ||
or the _sub_ version 0 context _c_. | ||
|
||
Message topics are used to filter messages. The first _sz_ bytes of an | ||
incoming message is compared against _buf_, and if equal the message | ||
is accepted and will be available for receiving. | ||
|
||
Multiple topics may be registered for the same socket or context, and | ||
incoming messages will be forwarded to the application if any of the topics match. | ||
|
||
TIP: To disable filtering altogether, the _buf_ may be `NULL` if _sz_ is zero. | ||
In this case, all messages will be forwarded to the application. | ||
|
||
TIP: These functions should be used instead of the `NNG_OPT_SUB_SUBSCRIBE` and | ||
`NNG_OPT_SUB_UNSUBSCRIBE` options. | ||
|
||
== RETURN VALUES | ||
|
||
These functions return 0 on success, and non-zero otherwise. | ||
|
||
== ERRORS | ||
|
||
[horizontal] | ||
`NNG_ENOMEM`:: Insufficient memory is available. | ||
`NNG_ENOTSUP`:: The protocol is not supported. | ||
`NNG_ENOENT`:: The topic is not subscribed. | ||
|
||
== SEE ALSO | ||
|
||
[.text-left] | ||
xref:nng_socket.5.adoc[nng_socket(5)], | ||
xref:nng_pub.7.adoc[nng_pub(7)], | ||
xref:nng_sub.7.adoc[nng_sub(7)], | ||
xref:nng.7.adoc[nng(7)] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright 2021 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2024 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2018 Capitar IT Group BV <[email protected]> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
|
@@ -26,7 +26,9 @@ extern bool nni_sock_raw(nni_sock *); | |
extern void *nni_sock_proto_data(nni_sock *); | ||
extern void nni_sock_add_stat(nni_sock *, nni_stat_item *); | ||
|
||
extern struct nni_proto_sock_ops *nni_sock_proto_ops(nni_sock *); | ||
extern struct nni_proto_pipe_ops *nni_sock_proto_pipe_ops(nni_sock *); | ||
extern struct nni_proto_ctx_ops *nni_ctx_proto_ops(nni_ctx *); | ||
|
||
extern int nni_sock_setopt( | ||
nni_sock *, const char *, const void *, size_t, nni_opt_type); | ||
|
@@ -89,6 +91,8 @@ extern void nni_ctx_close(nni_ctx *); | |
// nni_ctx_id returns the context ID, which can be used with nni_ctx_find. | ||
extern uint32_t nni_ctx_id(nni_ctx *); | ||
|
||
extern void *nni_ctx_proto_data(nni_ctx *); | ||
|
||
// nni_ctx_recv receives asynchronously. | ||
extern void nni_ctx_recv(nni_ctx *, nni_aio *); | ||
|
||
|
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.