+
+ /// This functions is called whenever another node attemps to open a channel to the local node.
+ /**
+ * The function is run in MeshLink's own thread.
+ * It is therefore important that the callback uses apprioriate methods (queues, pipes, locking, etc.)
+ * to pass data to or from the application's thread.
+ * The callback should also not block itself and return as quickly as possible.
+ *
+ * @param channel A handle for the incoming channel.
+ * @param port The port number the peer wishes to connect to.
+ * @param data A pointer to a buffer containing data already received. (Not yet used.)
+ * @param len The length of the data. (Not yet used.)
+ *
+ * @return This function should return true if the application accepts the incoming channel, false otherwise.
+ * If returning false, the channel is invalid and may not be used anymore.
+ */
+ virtual bool channel_accept(channel *channel, uint16_t port, const void *data, size_t len)
+ {
+ /* by default reject all channels */
+ return false;
+ }
+
+ /// This function is called by Meshlink for receiving data from a channel.
+ /**
+ * The function is run in MeshLink's own thread.
+ * It is therefore important that the callback uses apprioriate methods (queues, pipes, locking, etc.)
+ * to pass data to or from the application's thread.
+ * The callback should also not block itself and return as quickly as possible.
+ *
+ * @param channel A handle for the channel.
+ * @param data A pointer to a buffer containing data sent by the source.
+ * @param len The length of the data.
+ */
+ virtual void channel_receive(channel *channel, const void *data, size_t len) { /* do nothing */ }
+
+ /// This function is called by Meshlink when data can be send on a channel.
+ /**
+ * The function is run in MeshLink's own thread.
+ * It is therefore important that the callback uses apprioriate methods (queues, pipes, locking, etc.)
+ * to pass data to or from the application's thread.
+ *
+ * The callback should also not block itself and return as quickly as possible.
+ * @param channel A handle for the channel.
+ * @param len The maximum length of data that is guaranteed to be accepted by a call to channel_send().
+ */
+ virtual void channel_poll(channel *channel, size_t len) { /* do nothing */ }