mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-06 11:09:13 +00:00
Parse DNA replies with no phone or name gracefully
This commit is contained in:
parent
f78a4d69a2
commit
487eab49cd
@ -41,13 +41,13 @@ public class MdpDnaLookup extends ChannelSelector.Handler{
|
|||||||
response.payload.get(bytes);
|
response.payload.get(bytes);
|
||||||
String resultString = new String(bytes);
|
String resultString = new String(bytes);
|
||||||
String fields[] = resultString.split("\\|");
|
String fields[] = resultString.split("\\|");
|
||||||
if (fields.length < 4)
|
if (fields.length < 2)
|
||||||
throw new IOException("Expected 4 result fields");
|
throw new IOException("Expected at least 2 result fields, got \""+resultString+"\"");
|
||||||
ServalDCommand.LookupResult result = new ServalDCommand.LookupResult();
|
ServalDCommand.LookupResult result = new ServalDCommand.LookupResult();
|
||||||
result.subscriberId = new SubscriberId(fields[0]);
|
result.subscriberId = new SubscriberId(fields[0]);
|
||||||
result.uri = fields[1];
|
result.uri = fields[1];
|
||||||
result.did = fields[2];
|
result.did = (fields.length>2)?fields[2]:"";
|
||||||
result.name = fields[3];
|
result.name = (fields.length>3)?fields[3]:"";
|
||||||
results.result(result);
|
results.result(result);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user