Stay organized with collections
Save and categorize content based on your preferences.
gpg::MessageListenerHelper
#include <message_listener_helper.h>
Defines a helper which can be used to provide IMessageListener callbacks to the SDK without defining the full IMessageListener interface.
Summary
Callbacks configured on this object will be invoked as described in the nearby connections API. Callbacks not explicitly set will do nothing.
Public types
|
OnDisconnectedCallback
|
typedef
std::function< void(int64_t client_id, const std::string &remote_endpoint_id)>
OnDisconnectedCallback is called when a remote endpoint disconnects.
|
OnMessageReceivedCallback
|
typedef
std::function< void(int64_t client_id, const std::string &remote_endpoint_id, const std::vector< uint8_t > &payload, bool is_reliable)>
OnMessageReceivedCallback is called when a message is received from a remote endpoint.
|
Public types
OnDisconnectedCallback
std::function< void(int64_t client_id, const std::string &remote_endpoint_id)> OnDisconnectedCallback
OnDisconnectedCallback
is called when a remote endpoint disconnects.
client_id
is the ID of the NearbyConnections instance that received the disconnect message. remote_endpoint_id
is the ID of the remote endpoint that disconnected.
OnMessageReceivedCallback
std::function< void(int64_t client_id, const std::string &remote_endpoint_id, const std::vector< uint8_t > &payload, bool is_reliable)> OnMessageReceivedCallback
OnMessageReceivedCallback
is called when a message is received from a remote endpoint.
client_id
is the ID of the NearbyConnections instance that received this message. remote_endpoint_id
is the ID of the remote endpoint that sent the message. payload
contains the bytes of the message. is_reliable
is true if the message was sent reliably, false otherwise.
Public functions
MessageListenerHelper
MessageListenerHelper()
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-10-28 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-28 UTC."],[],[],null,["# gpg::MessageListenerHelper Class Reference\n\ngpg::MessageListenerHelper\n==========================\n\n`#include \u003cmessage_listener_helper.h\u003e`\n\nDefines a helper which can be used to provide [IMessageListener](/games/services/cpp/api/class/gpg/i-message-listener#classgpg_1_1_i_message_listener) callbacks to the SDK without defining the full [IMessageListener](/games/services/cpp/api/class/gpg/i-message-listener#classgpg_1_1_i_message_listener) interface.\n\nSummary\n-------\n\nCallbacks configured on this object will be invoked as described in the nearby connections API. Callbacks not explicitly set will do nothing.\n\n| ### Constructors and Destructors ||\n|---|---|\n| [MessageListenerHelper](#classgpg_1_1_message_listener_helper_1a1a0f7e5058bb0643907a39fa5bd61359)`()` ||\n| [MessageListenerHelper](#classgpg_1_1_message_listener_helper_1ae7d21da925a410f09068f0c662da5b0a)`(std::shared_ptr\u003c `[MessageListenerHelperImpl](/games/services/cpp/api/class/gpg/message-listener-helper#classgpg_1_1_message_listener_helper_1a8a1607bb0294cf8ed5df88cc63637a27)` \u003e impl)` Constructs a [MessageListenerHelper](/games/services/cpp/api/class/gpg/message-listener-helper#classgpg_1_1_message_listener_helper) from a `shared_ptr` to a `MessageListenerHelperImpl`. ||\n\n| ### Public types ||\n|-------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [OnDisconnectedCallback](#classgpg_1_1_message_listener_helper_1a7b743b43edec615e74e557c30854f4b5) | typedef `std::function\u003c void(int64_t client_id, const std::string &remote_endpoint_id)\u003e` `OnDisconnectedCallback` is called when a remote endpoint disconnects. |\n| [OnMessageReceivedCallback](#classgpg_1_1_message_listener_helper_1a5f501c5153160b0be39b1015e4d4f05d) | typedef `std::function\u003c void(int64_t client_id, const std::string &remote_endpoint_id, const std::vector\u003c uint8_t \u003e &payload, bool is_reliable)\u003e` `OnMessageReceivedCallback` is called when a message is received from a remote endpoint. |\n\n| ### Public functions ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [SetOnDisconnectedCallback](#classgpg_1_1_message_listener_helper_1abd29867a01f436524bea566327a14671)`(`[OnDisconnectedCallback](/games/services/cpp/api/class/gpg/message-listener-helper#classgpg_1_1_message_listener_helper_1a7b743b43edec615e74e557c30854f4b5)` callback)` | [MessageListenerHelper](/games/services/cpp/api/class/gpg/message-listener-helper#classgpg_1_1_message_listener_helper)` &` Set the OnDisconnectedCallback. |\n| [SetOnMessageReceivedCallback](#classgpg_1_1_message_listener_helper_1a82c81d521883dbe58e6195643a4c7b15)`(`[OnMessageReceivedCallback](/games/services/cpp/api/class/gpg/message-listener-helper#classgpg_1_1_message_listener_helper_1a5f501c5153160b0be39b1015e4d4f05d)` callback)` | [MessageListenerHelper](/games/services/cpp/api/class/gpg/message-listener-helper#classgpg_1_1_message_listener_helper)` &` Set the OnMessageReceivedCallback. |\n\nPublic types\n------------\n\n### OnDisconnectedCallback\n\n```c++\nstd::function\u003c void(int64_t client_id, const std::string &remote_endpoint_id)\u003e OnDisconnectedCallback\n``` \n`OnDisconnectedCallback` is called when a remote endpoint disconnects.\n\n`client_id` is the ID of the [NearbyConnections](/games/services/cpp/api/class/gpg/nearby-connections#classgpg_1_1_nearby_connections) instance that received the disconnect message. `remote_endpoint_id` is the ID of the remote endpoint that disconnected. \n\n### OnMessageReceivedCallback\n\n```c++\nstd::function\u003c void(int64_t client_id, const std::string &remote_endpoint_id, const std::vector\u003c uint8_t \u003e &payload, bool is_reliable)\u003e OnMessageReceivedCallback\n``` \n`OnMessageReceivedCallback` is called when a message is received from a remote endpoint.\n\n`client_id` is the ID of the [NearbyConnections](/games/services/cpp/api/class/gpg/nearby-connections#classgpg_1_1_nearby_connections) instance that received this message. `remote_endpoint_id` is the ID of the remote endpoint that sent the message. `payload` contains the bytes of the message. `is_reliable` is true if the message was sent reliably, false otherwise.\n\nPublic functions\n----------------\n\n### MessageListenerHelper\n\n```c++\n MessageListenerHelper()\n``` \n\n### MessageListenerHelper\n\n```c++\n MessageListenerHelper(\n std::shared_ptr\u003c MessageListenerHelperImpl \u003e impl\n)\n``` \nConstructs a [MessageListenerHelper](/games/services/cpp/api/class/gpg/message-listener-helper#classgpg_1_1_message_listener_helper) from a `shared_ptr` to a `MessageListenerHelperImpl`.\n\nIntended for internal use by the API. \n\n### SetOnDisconnectedCallback\n\n```c++\nMessageListenerHelper & SetOnDisconnectedCallback(\n OnDisconnectedCallback callback\n)\n``` \nSet the OnDisconnectedCallback. \n\n### SetOnMessageReceivedCallback\n\n```c++\nMessageListenerHelper & SetOnMessageReceivedCallback(\n OnMessageReceivedCallback callback\n)\n``` \nSet the OnMessageReceivedCallback."]]