public class WifiNanSessionListener extends Object
WifiNanManager.publish(PublishData, PublishSettings, WifiNanSessionListener, int)
or
WifiNanManager.subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)
. These are callbacks applying to a specific NAN session. Events
corresponding to the NAN link are delivered using WifiNanEventListener
.
A single listener is registered at session creation - it cannot be replaced.
During registration specify which specific events are desired using a set of
NanSessionListener.LISTEN_*
flags OR'd together. Only those events
will be delivered to the registered listener. Override those callbacks
NanSessionListener.on*
for the registered events.
Modifier and Type | Field and Description |
---|---|
IWifiNanSessionListener |
callback |
static int |
FAIL_REASON_INVALID_ARGS
Failure reason flag for
WifiNanEventListener and
WifiNanSessionListener callbacks. |
static int |
FAIL_REASON_NO_MATCH_SESSION
Failure reason flag for
WifiNanEventListener and
WifiNanSessionListener callbacks. |
static int |
FAIL_REASON_NO_RESOURCES
Failure reason flag for
WifiNanEventListener and
WifiNanSessionListener callbacks. |
static int |
FAIL_REASON_OTHER
Failure reason flag for
WifiNanEventListener and
WifiNanSessionListener callbacks. |
static int |
LISTEN_HIDDEN_FLAGS
List of hidden events: which are mandatory - i.e. they will be added to
every request.
|
static int |
LISTEN_MATCH
Match (discovery: publish or subscribe) callback event registration flag.
|
static int |
LISTEN_MESSAGE_RECEIVED
Message received callback event registration flag.
|
static int |
LISTEN_MESSAGE_SEND_FAIL
Message sending failure callback event registration flag.
|
static int |
LISTEN_MESSAGE_SEND_SUCCESS
Message sent successfully callback event registration flag.
|
static int |
LISTEN_PUBLISH_FAIL
Publish fail callback event registration flag.
|
static int |
LISTEN_PUBLISH_TERMINATED
Publish terminated callback event registration flag.
|
static int |
LISTEN_SUBSCRIBE_FAIL
Subscribe fail callback event registration flag.
|
static int |
LISTEN_SUBSCRIBE_TERMINATED
Subscribe terminated callback event registration flag.
|
static int |
TERMINATE_REASON_DONE
Failure reason flag for
onPublishTerminated(int) and
onSubscribeTerminated(int) callbacks. |
static int |
TERMINATE_REASON_FAIL
Failure reason flag for
onPublishTerminated(int) and
onSubscribeTerminated(int) callbacks. |
Constructor and Description |
---|
WifiNanSessionListener()
Constructs a
WifiNanSessionListener using the looper of the current
thread. |
WifiNanSessionListener(Looper looper)
Constructs a
WifiNanSessionListener using the specified looper. |
Modifier and Type | Method and Description |
---|---|
void |
onMatch(int peerId,
byte[] serviceSpecificInfo,
int serviceSpecificInfoLength,
byte[] matchFilter,
int matchFilterLength)
Called when a discovery (publish or subscribe) operation results in a
match - i.e. when a peer is discovered.
|
void |
onMessageReceived(int peerId,
byte[] message,
int messageLength)
Called when a message is received from a discovery session peer.
|
void |
onMessageSendFail(int messageId,
int reason)
Called when a message transmission fails - i.e. when no ACK is received.
|
void |
onMessageSendSuccess(int messageId)
Called when a message is transmitted successfully - i.e. when we know
that it was received successfully (corresponding to an ACK being
received).
|
void |
onPublishFail(int reason)
Called when a publish operation fails.
|
void |
onPublishTerminated(int reason)
Called when a publish operation terminates.
|
void |
onSubscribeFail(int reason)
Called when a subscribe operation fails.
|
void |
onSubscribeTerminated(int reason)
Called when a subscribe operation terminates.
|
public static final int LISTEN_PUBLISH_FAIL
onPublishFail(int)
.public static final int LISTEN_PUBLISH_TERMINATED
onPublishTerminated(int)
.public static final int LISTEN_SUBSCRIBE_FAIL
onSubscribeFail(int)
.public static final int LISTEN_SUBSCRIBE_TERMINATED
onSubscribeTerminated(int)
.public static final int LISTEN_MATCH
onMatch(int, byte[], int, byte[], int)
.public static final int LISTEN_MESSAGE_SEND_SUCCESS
WifiNanSessionListener#onMessageSendSuccess()
.public static final int LISTEN_MESSAGE_SEND_FAIL
WifiNanSessionListener#onMessageSendFail(int)
.public static final int LISTEN_MESSAGE_RECEIVED
onMessageReceived(int, byte[], int)
.public static final int LISTEN_HIDDEN_FLAGS
public static final int FAIL_REASON_NO_RESOURCES
WifiNanEventListener
and
WifiNanSessionListener
callbacks. Indicates no resources to execute
the requested operation.public static final int FAIL_REASON_INVALID_ARGS
WifiNanEventListener
and
WifiNanSessionListener
callbacks. Indicates invalid argument in the
requested operation.public static final int FAIL_REASON_NO_MATCH_SESSION
WifiNanEventListener
and
WifiNanSessionListener
callbacks. Indicates a message is transmitted
without a match (i.e. a discovery) occurring first.public static final int FAIL_REASON_OTHER
WifiNanEventListener
and
WifiNanSessionListener
callbacks. Indicates an unspecified error
occurred during the operation.public static final int TERMINATE_REASON_DONE
onPublishTerminated(int)
and
onSubscribeTerminated(int)
callbacks.
Indicates that publish or subscribe session is done - i.e. all the
requested operations (per PublishSettings
or
SubscribeSettings
) have been executed.public static final int TERMINATE_REASON_FAIL
onPublishTerminated(int)
and
onSubscribeTerminated(int)
callbacks.
Indicates that publish or subscribe session is terminated due to a
failure.public IWifiNanSessionListener callback
public WifiNanSessionListener()
WifiNanSessionListener
using the looper of the current
thread. I.e. all callbacks will be delivered on the current thread.public WifiNanSessionListener(Looper looper)
WifiNanSessionListener
using the specified looper. I.e.
all callbacks will delivered on the thread of the specified looper.looper
- The looper on which to execute the callbacks.public void onPublishFail(int reason)
reason
- The failure reason using NanSessionListener.FAIL_*
codes.public void onPublishTerminated(int reason)
LISTEN_PUBLISH_TERMINATED
.
A dummy (empty implementation printing out a warning). Make sure to
override if registered.reason
- The termination reason using
NanSessionListener.TERMINATE_*
codes.public void onSubscribeFail(int reason)
reason
- The failure reason using NanSessionListener.FAIL_*
codes.public void onSubscribeTerminated(int reason)
LISTEN_SUBSCRIBE_TERMINATED
. A dummy (empty
implementation printing out a warning). Make sure to override if
registered.reason
- The termination reason using
NanSessionListener.TERMINATE_*
codes.public void onMatch(int peerId, byte[] serviceSpecificInfo, int serviceSpecificInfoLength, byte[] matchFilter, int matchFilterLength)
peerId
- The ID of the peer matching our discovery operation.serviceSpecificInfo
- The service specific information (arbitrary
byte array) provided by the peer as part of its discovery
packet.serviceSpecificInfoLength
- The length of the service specific
information array.matchFilter
- The filter (Tx on advertiser and Rx on listener) which
resulted in this match.matchFilterLength
- The length of the match filter array.public void onMessageSendSuccess(int messageId)
Note that either this callback or
onMessageSendFail(int, int)
will be
received - never both.
public void onMessageSendFail(int messageId, int reason)
Note that either this callback or
onMessageSendSuccess(int)
will be received
- never both
reason
- The failure reason using NanSessionListener.FAIL_*
codes.public void onMessageReceived(int peerId, byte[] message, int messageLength)
peerId
- The ID of the peer sending the message.message
- A byte array containing the message.messageLength
- The length of the byte array containing the relevant
message bytes.