Convert presence notification response to user list
This commit is contained in:
parent
728d65f220
commit
ede9b259d4
1 changed files with 12 additions and 4 deletions
|
@ -12,6 +12,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Handles connection to the default INSA Clavardator presence server.
|
||||
|
@ -76,12 +77,19 @@ public class InsaPresence implements Presence {
|
|||
private void receiveSubscribeNotifications(ParametrizedCallback<ArrayList<UserInformation>> callback, @Nullable ErrorCallback errorCallback) {
|
||||
presenceConnection.receive(
|
||||
msg -> {
|
||||
// TODO decide what we should receive
|
||||
final ArrayList<UserInformation> test = new ArrayList<>();
|
||||
test.add(new UserInformation("test", "test"));
|
||||
final ArrayList<UserInformation> userList = new ArrayList<>();
|
||||
if (msg instanceof ArrayList<?>) {
|
||||
final ArrayList<?> list = (ArrayList<?>) msg;
|
||||
for (Object obj : list) {
|
||||
if (obj instanceof UserInformation) {
|
||||
userList.add((UserInformation)obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.v(getClass().getSimpleName(), "Receive subscribe response: " + msg);
|
||||
Log.v(getClass().getSimpleName(), "Converted list: " + Arrays.toString(userList.toArray()));
|
||||
if (callback != null) {
|
||||
callback.call(test);
|
||||
callback.call(userList);
|
||||
}
|
||||
}, errorCallback);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue