WifiP2pUpnpServiceResponsepublic class WifiP2pUpnpServiceResponse extends WifiP2pServiceResponse A class for a response of upnp service discovery. |
Fields Summary |
---|
private int | mVersionUPnP version. should be {@link WifiP2pUpnpServiceInfo#VERSION_1_0} | private List | mUniqueServiceNamesThe list of Unique Service Name.
e.g)
{"uuid:6859dede-8574-59ab-9332-123456789012",
"uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice"} |
Constructors Summary |
---|
protected WifiP2pUpnpServiceResponse(int status, int transId, android.net.wifi.p2p.WifiP2pDevice dev, byte[] data)hidden constructor.
super(WifiP2pServiceInfo.SERVICE_TYPE_UPNP,
status, transId, dev, data);
if (!parse()) {
throw new IllegalArgumentException("Malformed upnp service response");
}
|
Methods Summary |
---|
public java.util.List | getUniqueServiceNames()Return Unique Service Name strings.
return mUniqueServiceNames;
| public int | getVersion()Return UPnP version number.
return mVersion;
| static android.net.wifi.p2p.nsd.WifiP2pUpnpServiceResponse | newInstance(int status, int transId, android.net.wifi.p2p.WifiP2pDevice device, byte[] data)Create upnp service response.
This is only used in{@link WifiP2pServiceResponse}
if (status != WifiP2pServiceResponse.Status.SUCCESS) {
return new WifiP2pUpnpServiceResponse(status, transId, device, null);
}
try {
return new WifiP2pUpnpServiceResponse(status, transId, device, data);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
return null;
| private boolean | parse()Parse UPnP service discovery response
/*
* The data format is as follows.
*
* ______________________________________________________
* | Version (1) | USN (Variable) |
*/
if (mData == null) {
// the empty is OK.
return true;
}
if (mData.length < 1) {
return false;
}
mVersion = mData[0] & 0xff;
String[] names = new String(mData, 1, mData.length-1).split(",");
mUniqueServiceNames = new ArrayList<String>();
for (String name : names) {
mUniqueServiceNames.add(name);
}
return true;
| public java.lang.String | toString()
StringBuffer sbuf = new StringBuffer();
sbuf.append("serviceType:UPnP(").append(mServiceType).append(")");
sbuf.append(" status:").append(Status.toString(mStatus));
sbuf.append(" srcAddr:").append(mDevice.deviceAddress);
sbuf.append(" version:").append(String.format("%02x", mVersion));
if (mUniqueServiceNames != null) {
for (String name : mUniqueServiceNames) {
sbuf.append(" usn:").append(name);
}
}
return sbuf.toString();
|
|