-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK: UISI AutoReporting #1386
SDK: UISI AutoReporting #1386
Changes from 9 commits
190678c
a456229
a2ec902
6fe5744
6a6f3c2
a5e8910
47964a4
00ac153
19574c6
0c63deb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
|
||
#import "MXDeviceListResponse.h" | ||
|
||
#import "MatrixSDKSwiftHeader.h" | ||
/** | ||
The store to use for crypto. | ||
*/ | ||
|
@@ -817,6 +818,24 @@ - (void)handleDeviceListsChanges:(MXDeviceListResponse*)deviceLists | |
#endif | ||
} | ||
|
||
- (void)handleToDeviceEvent:(MXEvent *)event onComplete:(void (^)(void))onComplete | ||
{ | ||
switch (event.eventType) | ||
{ | ||
case MXEventTypeRoomKey: | ||
{ | ||
[self handleRoomKeyEvent:event onComplete:onComplete]; | ||
break; | ||
} | ||
|
||
default: | ||
onComplete(); | ||
break; | ||
} | ||
[self.mxSession.eventStreamService dispatchOnLiveToDeviceWithEvent:event]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
|
||
- (void)handleRoomKeyEvent:(MXEvent*)event onComplete:(void (^)(void))onComplete | ||
{ | ||
// Use decryptionQueue as synchronisation because decryptions require room keys | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// Copyright 2022 The Matrix.org Foundation C.I.C | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Manages the adding, removing MXLiveEventListeners and dispatching of events to those listeners. | ||
@objcMembers public class MXEventStreamService: NSObject { | ||
|
||
var listeners = [MXLiveEventListener]() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yea nice and |
||
|
||
public func add(eventStreamListener: MXLiveEventListener) { | ||
listeners.append(eventStreamListener) | ||
} | ||
|
||
public func remove(eventStreamListener: MXLiveEventListener) { | ||
listeners.removeAll { $0 === eventStreamListener } | ||
} | ||
|
||
public func dispatchSessionStateChanged(state: MXSessionState) { | ||
listeners.forEach { listener in | ||
listener.onSessionStateChanged(state: state) | ||
} | ||
} | ||
|
||
public func dispatchLiveEventDecryptionAttempted(event: MXEvent, result: MXEventDecryptionResult) { | ||
listeners.forEach { listener in | ||
listener.onLiveEventDecryptionAttempted(event: event, result: result) | ||
} | ||
} | ||
|
||
public func dispatchOnLiveToDevice(event: MXEvent) { | ||
listeners.forEach { listener in | ||
listener.onLiveToDeviceEvent(event: event) | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// Copyright 2022 The Matrix.org Foundation C.I.C | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
/// Protocol used to monitor events of a specific session | ||
public protocol MXLiveEventListener: AnyObject { | ||
|
||
/// Monitor changes to session state | ||
func onSessionStateChanged(state: MXSessionState) | ||
|
||
/// Monitor decryption attempts | ||
func onLiveEventDecryptionAttempted(event: MXEvent, result:MXEventDecryptionResult) | ||
|
||
/// Monitor to device events | ||
func onLiveToDeviceEvent(event: MXEvent) | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be an important breaking change. Is it OK for you @manuroe ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for a bit of context. The function becomes a bit more general, so not just handling
RoomKeyEvent
but handles toDeviceEvents generally. The code to handleRoomKeyEvent
is unchanged. The naming also made some of the code read better like here. It also matches the android implementation now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From chatting to Gil I think functionally we are happy with the changes, it was just the breaking change. I think I'm happy with the breaking changed based off previous conversations with @manuroe . But will catch up with him when he's back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not against the change of this API. Plus, it seems it is used only internally.
But I wonder if we really this method. See my review comment.