# Print output for @column tags ?>
public
class
DiscoverySessionCallback
extends Object
java.lang.Object | |
↳ | android.net.wifi.aware.DiscoverySessionCallback |
Base class for Aware session events callbacks. Should be extended by
applications wanting notifications. The callbacks are set when a
publish or subscribe session is created using
WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
android.os.Handler)
or
WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback,
android.os.Handler)
.
A single callback is set at session creation - it cannot be replaced.
Public constructors | |
---|---|
DiscoverySessionCallback()
|
Public methods | |
---|---|
void
|
onMessageReceived(PeerHandle peerHandle, byte[] message)
Called when a message is received from a discovery session peer - in response to the
peer's |
void
|
onMessageSendFailed(int messageId)
Called when message transmission initiated with
|
void
|
onMessageSendSucceeded(int messageId)
Called in response to
|
void
|
onPublishStarted(PublishDiscoverySession session)
Called when a publish operation is started successfully in response to a
|
void
|
onServiceDiscovered(PeerHandle peerHandle, byte[] serviceSpecificInfo, List<byte[]> matchFilter)
Called when a discovery (publish or subscribe) operation results in a service discovery. |
void
|
onServiceDiscoveredWithinRange(PeerHandle peerHandle, byte[] serviceSpecificInfo, List<byte[]> matchFilter, int distanceMm)
Called when a discovery (publish or subscribe) operation results in a service discovery. |
void
|
onServiceLost(PeerHandle peerHandle, int reason)
Called when the discovered service is not available. |
void
|
onSessionConfigFailed()
Called when a publish or subscribe discovery session cannot be created:
|
void
|
onSessionConfigUpdated()
Called when a publish or subscribe discovery session configuration update request succeeds. |
void
|
onSessionTerminated()
Called when a discovery session (publish or subscribe) terminates. |
void
|
onSubscribeStarted(SubscribeDiscoverySession session)
Called when a subscribe operation is started successfully in response to a
|
Inherited methods | |
---|---|
public DiscoverySessionCallback ()
public void onMessageReceived (PeerHandle peerHandle, byte[] message)
Called when a message is received from a discovery session peer - in response to the
peer's DiscoverySession#sendMessage(PeerHandle, int, byte[])
.
Parameters | |
---|---|
peerHandle |
PeerHandle : An opaque handle to the peer matching our discovery operation. |
message |
byte : A byte array containing the message. |
public void onMessageSendFailed (int messageId)
Called when message transmission initiated with
DiscoverySession#sendMessage(PeerHandle, int, byte[])
fails. E.g. when no ACK is
received from the peer.
Note that either this callback or
DiscoverySessionCallback#onMessageSendSucceeded(int)
will be received
- never both.
Parameters | |
---|---|
messageId |
int : The arbitrary message ID specified when sending the message. |
public void onMessageSendSucceeded (int messageId)
Called in response to
DiscoverySession#sendMessage(PeerHandle, int, byte[])
when a message is transmitted successfully - i.e. when it was received successfully by the
peer (corresponds to an ACK being received).
Note that either this callback or
DiscoverySessionCallback#onMessageSendFailed(int)
will be
received - never both.
Parameters | |
---|---|
messageId |
int : The arbitrary message ID specified when sending the message. |
public void onPublishStarted (PublishDiscoverySession session)
Called when a publish operation is started successfully in response to a
WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
android.os.Handler)
operation.
Parameters | |
---|---|
session |
PublishDiscoverySession : The PublishDiscoverySession used to control the
discovery session.
This value cannot be null . |
public void onServiceDiscovered (PeerHandle peerHandle, byte[] serviceSpecificInfo, List<byte[]> matchFilter)
Called when a discovery (publish or subscribe) operation results in a service discovery.
Note that this method and
onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle, byte[], java.util.List, int)
may be called
multiple times per service discovery.
Parameters | |
---|---|
peerHandle |
PeerHandle : An opaque handle to the peer matching our discovery operation. |
serviceSpecificInfo |
byte : The service specific information (arbitrary
byte array) provided by the peer as part of its discovery
configuration. |
matchFilter |
List : The filter which resulted in this service discovery. For
PublishConfig#PUBLISH_TYPE_UNSOLICITED ,
SubscribeConfig#SUBSCRIBE_TYPE_PASSIVE discovery sessions this is the publisher's
match filter. For PublishConfig#PUBLISH_TYPE_SOLICITED ,
SubscribeConfig#SUBSCRIBE_TYPE_ACTIVE discovery sessions this
is the subscriber's match filter. |
public void onServiceDiscoveredWithinRange (PeerHandle peerHandle, byte[] serviceSpecificInfo, List<byte[]> matchFilter, int distanceMm)
Called when a discovery (publish or subscribe) operation results in a
service discovery. Called when a Subscribe service was configured with a range requirement
SubscribeConfig.Builder#setMinDistanceMm(int)
and/or
SubscribeConfig.Builder#setMaxDistanceMm(int)
and the Publish service was configured
with PublishConfig.Builder#setRangingEnabled(boolean)
.
If either Publisher or Subscriber does not enable Ranging, or if Ranging is temporarily
disabled by the underlying device, service discovery proceeds without ranging and the
onServiceDiscovered(android.net.wifi.aware.PeerHandle, byte[], java.util.List)
is called.
Note that this method and onServiceDiscovered(android.net.wifi.aware.PeerHandle, byte[], java.util.List)
may be
called multiple times per service discovery.
Parameters | |
---|---|
peerHandle |
PeerHandle : An opaque handle to the peer matching our discovery operation. |
serviceSpecificInfo |
byte : The service specific information (arbitrary
byte array) provided by the peer as part of its discovery
configuration. |
matchFilter |
List : The filter which resulted in this service discovery. For
PublishConfig#PUBLISH_TYPE_UNSOLICITED ,
SubscribeConfig#SUBSCRIBE_TYPE_PASSIVE discovery sessions this is the publisher's
match filter. For PublishConfig#PUBLISH_TYPE_SOLICITED ,
SubscribeConfig#SUBSCRIBE_TYPE_ACTIVE discovery sessions this
is the subscriber's match filter. |
distanceMm |
int : The measured distance to the Publisher in mm. Note: the measured distance
may be negative for very close devices. |
public void onServiceLost (PeerHandle peerHandle, int reason)
Called when the discovered service is not available. All further operations on this
discovery session will fail. If the service is available again,
onServiceDiscovered(android.net.wifi.aware.PeerHandle, byte[], java.util.List)
or
onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle, byte[], java.util.List, int)
will be called.
Parameters | |
---|---|
peerHandle |
PeerHandle : An opaque handle to the peer matching our discovery operation.
This value cannot be null . |
reason |
int : Discovered service lost reason code. One of
WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE ,
WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN
|
public void onSessionConfigFailed ()
Called when a publish or subscribe discovery session cannot be created:
WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
android.os.Handler)
or
WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback,
android.os.Handler)
, or when a configuration update fails:
PublishDiscoverySession#updatePublish(PublishConfig)
or
SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)
.
For discovery session updates failure leaves the session running with its previous configuration - the discovery session is not terminated.
public void onSessionConfigUpdated ()
Called when a publish or subscribe discovery session configuration update request
succeeds. Called in response to
PublishDiscoverySession#updatePublish(PublishConfig)
or
SubscribeDiscoverySession#updateSubscribe(SubscribeConfig)
.
public void onSessionTerminated ()
Called when a discovery session (publish or subscribe) terminates. Termination may be due
to user-request (either directly through DiscoverySession#close()
or
application-specified expiration, e.g. PublishConfig.Builder#setTtlSec(int)
or SubscribeConfig.Builder#setTtlSec(int)
).
public void onSubscribeStarted (SubscribeDiscoverySession session)
Called when a subscribe operation is started successfully in response to a
WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback,
android.os.Handler)
operation.
Parameters | |
---|---|
session |
SubscribeDiscoverySession : The SubscribeDiscoverySession used to control the
discovery session.
This value cannot be null . |