Skip to content
Snippets Groups Projects
Commit fd2c3787 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Kateryna Kostiuk
Browse files

notifications: stream HTTP data instead of waiting for response

The proxy-server route /{key} produces a HTTP stream which reflects values obtained by a DHT get. The stream is not guaranteed to signal termination. Previously we were waiting on a complete response which in several scenarios would never arrive. This causes the stream data to not be parsed, and for the URLSession block until a timeout, which would cause queueing of any incoming notifications.

This commit changes the design to stream the HTTP content and handle lines (JSON) asynchronously as they are received.

Gitlab: #359
Change-Id: I469bdde0a3c1ad9d0ac46285740c0f55fd377018
parent 1dea47fc
Branches
No related tags found
No related merge requests found
......@@ -24,3 +24,6 @@ Ring/Build/
# Carthage
Ring/Carthage/
# VSCode
.vscode/
\ No newline at end of file
......@@ -457,6 +457,7 @@
5CE66F761FBF769B00EE9291 /* InitialLoadingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CE66F741FBF769B00EE9291 /* InitialLoadingViewController.swift */; };
62006E04203F4DD6003C3197 /* UITextField+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62006E03203F4DD6003C3197 /* UITextField+Helpers.swift */; };
621231F91F880EDF009B86F0 /* UILabel+Ring.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621231F81F880EDF009B86F0 /* UILabel+Ring.swift */; };
623196862BAE498900C2252C /* Atomics in Frameworks */ = {isa = PBXBuildFile; productRef = 623196852BAE498900C2252C /* Atomics */; };
623660AA20092081002598C1 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 623660A920092081002598C1 /* src */; };
627F11F120348FBF006560B5 /* AvatarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 627F11F020348FBF006560B5 /* AvatarView.swift */; };
62A88D371F6C2ED400F8AB18 /* PresenceAdapterDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A88D361F6C2ED400F8AB18 /* PresenceAdapterDelegate.swift */; };
......@@ -1286,6 +1287,7 @@
269DA02E28D0D2E5007D51D6 /* libgmp.a in Frameworks */,
269DA07F28D0D5D0007D51D6 /* libgit2.a in Frameworks */,
269DA02B28D0D2E5007D51D6 /* libavformat.a in Frameworks */,
623196862BAE498900C2252C /* Atomics in Frameworks */,
26A88C7826700B7500888EED /* libc++.tbd in Frameworks */,
269DA03E28D0D2E5007D51D6 /* libpjsip-simple.a in Frameworks */,
26CA4C592AB23C4100AEF8F5 /* libixml.a in Frameworks */,
......@@ -2574,6 +2576,9 @@
dependencies = (
);
name = jamiNotificationExtension;
packageProductDependencies = (
623196852BAE498900C2252C /* Atomics */,
);
productName = jamiNotificationExtension;
productReference = 26A88C04266FFFC800888EED /* jamiNotificationExtension.appex */;
productType = "com.apple.product-type.app-extension";
......@@ -2692,6 +2697,7 @@
mainGroup = 043999EA1D1C2D9D00E99CD9;
packageReferences = (
5593D7D12B7FE00A00DA109C /* XCRemoteSwiftPackageReference "MCEmojiPicker" */,
623196842BAE498900C2252C /* XCRemoteSwiftPackageReference "swift-atomics" */,
);
productRefGroup = 043999F41D1C2D9D00E99CD9 /* Products */;
projectDirPath = "";
......@@ -4140,6 +4146,14 @@
minimumVersion = 1.2.3;
};
};
623196842BAE498900C2252C /* XCRemoteSwiftPackageReference "swift-atomics" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-atomics.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.2.0;
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
......@@ -4148,6 +4162,11 @@
package = 5593D7D12B7FE00A00DA109C /* XCRemoteSwiftPackageReference "MCEmojiPicker" */;
productName = MCEmojiPicker;
};
623196852BAE498900C2252C /* Atomics */ = {
isa = XCSwiftPackageProductDependency;
package = 623196842BAE498900C2252C /* XCRemoteSwiftPackageReference "swift-atomics" */;
productName = Atomics;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 043999EB1D1C2D9D00E99CD9 /* Project object */;
......
......@@ -45,7 +45,7 @@ using namespace libjami;
- (BOOL) initDaemonInternal {
#if DEBUG
int flag = LIBJAMI_FLAG_CONSOLE_LOG | LIBJAMI_FLAG_DEBUG;
int flag = 0;
#else
int flag = 0;
#endif
......
......@@ -106,6 +106,7 @@ public class Constants: NSObject {
@objc public static let updatedConversations = "updatedConversations"
@objc public static let appGroupIdentifier = "group.com.savoirfairelinux.ring"
@objc public static let notificationsCount = "notificationsCount"
@objc public static let appIdentifier = "com.savoirfairelinux.jami"
@objc public static let documentsPath: URL? = {
return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.appendingPathComponent("Documents")
......
......@@ -179,10 +179,9 @@ std::map<std::string, std::string> nameServers;
loadAccountAndConversation(std::string([accountId UTF8String]), loadAll, std::string([convId UTF8String]));
return true;
}
#if DEBUG
int flag = LIBJAMI_FLAG_CONSOLE_LOG | LIBJAMI_FLAG_DEBUG | LIBJAMI_FLAG_IOS_EXTENSION | LIBJAMI_FLAG_NO_AUTOSYNC | LIBJAMI_FLAG_NO_LOCAL_AUDIO | LIBJAMI_FLAG_NO_AUTOLOAD;
#else
int flag = LIBJAMI_FLAG_IOS_EXTENSION | LIBJAMI_FLAG_NO_AUTOSYNC | LIBJAMI_FLAG_NO_LOCAL_AUDIO | LIBJAMI_FLAG_NO_AUTOLOAD;
#if DEBUG
flag |= LIBJAMI_FLAG_CONSOLE_LOG | LIBJAMI_FLAG_DEBUG;
#endif
if (![[NSThread currentThread] isMainThread]) {
__block bool success;
......@@ -236,6 +235,7 @@ std::map<std::string, std::string> nameServers;
return {};
}
// Build the key using the key path argument
NSData* data = [[NSFileManager defaultManager] contentsAtPath:keyPath];
const uint8_t* bytes = (const uint8_t*) [data bytes];
dht::crypto::PrivateKey dhtKey(bytes, [data length], "");
......
......@@ -108,6 +108,9 @@ class AdapterService {
}
func decrypt(keyPath: String, accountId: String, messagesPath: String, value: [String: Any]) -> PeerConnectionRequestType {
if self.adapter == nil {
return .unknown
}
let result = adapter.decrypt(keyPath, accountId: accountId, treated: messagesPath, value: value)
guard let peerId = result?.keys.first,
let type = result?.values.first else {
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment