mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Handle end session messages
This commit is contained in:
parent
01702276c5
commit
1b0df2c7e7
3 changed files with 10 additions and 7 deletions
|
@ -7,10 +7,7 @@ import org.whispersystems.libaxolotl.state.SessionRecord;
|
|||
import org.whispersystems.libaxolotl.state.SessionStore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class JsonSessionStore implements SessionStore {
|
||||
|
||||
|
@ -85,7 +82,7 @@ public class JsonSessionStore implements SessionStore {
|
|||
|
||||
@Override
|
||||
public synchronized void deleteAllSessions(String name) {
|
||||
for (AxolotlAddress key : sessions.keySet()) {
|
||||
for (AxolotlAddress key : new ArrayList<>(sessions.keySet())) {
|
||||
if (key.getName().equals(name)) {
|
||||
sessions.remove(key);
|
||||
}
|
||||
|
|
|
@ -188,9 +188,11 @@ public class Main {
|
|||
} else {
|
||||
if (content.getDataMessage().isPresent()) {
|
||||
TextSecureDataMessage message = content.getDataMessage().get();
|
||||
|
||||
System.out.println("Body: " + message.getBody().get());
|
||||
if (message.getAttachments().isPresent()) {
|
||||
|
||||
if (message.isEndSession()) {
|
||||
m.handleEndSession(envelope.getSource());
|
||||
} else if (message.getAttachments().isPresent()) {
|
||||
System.out.println("Attachments: ");
|
||||
for (TextSecureAttachment attachment : message.getAttachments().get()) {
|
||||
System.out.println("- " + attachment.getContentType() + " (" + (attachment.isPointer() ? "Pointer" : "") + (attachment.isStream() ? "Stream" : "") + ")");
|
||||
|
|
|
@ -179,6 +179,10 @@ public class Manager {
|
|||
}
|
||||
}
|
||||
|
||||
public void handleEndSession(String source) {
|
||||
axolotlStore.deleteAllSessions(source);
|
||||
}
|
||||
|
||||
public interface ReceiveMessageHandler {
|
||||
void handleMessage(TextSecureEnvelope envelope);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue