mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Add a method for checking whether we can send streams.
This commit is contained in:
@@ -160,6 +160,12 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendOutgoingStreams(ContactId c, TransportId t) {
|
||||
TransportKeyManager m = managers.get(t);
|
||||
return m == null ? false : m.canSendOutgoingStreams(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamContext getStreamContext(ContactId c, TransportId t)
|
||||
throws DbException {
|
||||
|
||||
@@ -29,6 +29,8 @@ interface TransportKeyManager {
|
||||
|
||||
void removeContact(ContactId c);
|
||||
|
||||
boolean canSendOutgoingStreams(ContactId c);
|
||||
|
||||
@Nullable
|
||||
StreamContext getStreamContext(Transaction txn, ContactId c)
|
||||
throws DbException;
|
||||
|
||||
@@ -278,6 +278,21 @@ class TransportKeyManagerImpl implements TransportKeyManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSendOutgoingStreams(ContactId c) {
|
||||
lock.lock();
|
||||
try {
|
||||
MutableKeySet ks = outContexts.get(c);
|
||||
if (ks == null) return false;
|
||||
MutableOutgoingKeys outKeys =
|
||||
ks.getTransportKeys().getCurrentOutgoingKeys();
|
||||
if (!outKeys.isActive()) throw new AssertionError();
|
||||
return outKeys.getStreamCounter() <= MAX_32_BIT_UNSIGNED;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamContext getStreamContext(Transaction txn, ContactId c)
|
||||
throws DbException {
|
||||
|
||||
Reference in New Issue
Block a user