DiscoverySession.SendMessage(PeerHandle, Int32, Byte[]) Method

Definition

Sends a message to the specified destination.

[Android.Runtime.Register("sendMessage", "(Landroid/net/wifi/aware/PeerHandle;I[B)V", "GetSendMessage_Landroid_net_wifi_aware_PeerHandle_IarrayBHandler", ApiSince=26)]
public virtual void SendMessage (Android.Net.Wifi.Aware.PeerHandle peerHandle, int messageId, byte[]? message);
[<Android.Runtime.Register("sendMessage", "(Landroid/net/wifi/aware/PeerHandle;I[B)V", "GetSendMessage_Landroid_net_wifi_aware_PeerHandle_IarrayBHandler", ApiSince=26)>]
abstract member SendMessage : Android.Net.Wifi.Aware.PeerHandle * int * byte[] -> unit
override this.SendMessage : Android.Net.Wifi.Aware.PeerHandle * int * byte[] -> unit

Parameters

peerHandle
PeerHandle

The peer's handle for the message. Must be a result of an DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[], java.util.List) or DiscoverySessionCallback#onMessageReceived(PeerHandle, byte[]) events.

messageId
Int32

An arbitrary integer used by the caller to identify the message. The same integer ID will be returned in the callbacks indicating message send success or failure. The messageId is not used internally by the Aware service - it can be arbitrary and non-unique.

message
Byte[]

The message to be transmitted.

Attributes

Remarks

Sends a message to the specified destination. Aware messages are transmitted in the context of a discovery session - executed subsequent to a publish/subscribe DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[], java.util.List) event.

Aware messages are not guaranteed delivery. Callbacks on DiscoverySessionCallback indicate message was transmitted successfully, DiscoverySessionCallback#onMessageSendSucceeded(int), or transmission failed (possibly after several retries) - DiscoverySessionCallback#onMessageSendFailed(int).

The peer will get a callback indicating a message was received using DiscoverySessionCallback#onMessageReceived(PeerHandle, byte[]).

Java documentation for android.net.wifi.aware.DiscoverySession.sendMessage(android.net.wifi.aware.PeerHandle, int, byte[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to