@@ -15,7 +15,6 @@ limitations under the License.
15
15
*/
16
16
import type { IMentions } from "../matrix.ts" ;
17
17
import type { CallMembership } from "./CallMembership.ts" ;
18
- import type { Focus } from "./focus.ts" ;
19
18
20
19
export interface EncryptionKeyEntry {
21
20
index : number ;
@@ -49,71 +48,28 @@ export enum Status {
49
48
Unknown = "Unknown" ,
50
49
}
51
50
52
- export enum MembershipManagerEvent {
53
- StatusChanged = "StatusChanged" ,
54
- }
55
-
56
- export type MembershipManagerEventHandlerMap = {
57
- [ MembershipManagerEvent . StatusChanged ] : ( prefStatus : Status , newStatus : Status ) => void ;
58
- } ;
59
-
60
51
/**
61
- * This interface defines what a MembershipManager uses and exposes.
62
- * This interface is what we use to write tests and allows changing the actual implementation
63
- * without breaking tests because of some internal method renaming.
64
- *
65
- * @internal
52
+ * A type collecting call encryption statistics for a session.
66
53
*/
67
- export interface IMembershipManager {
68
- /**
69
- * If we are trying to join, or have successfully joined the session.
70
- * It does not reflect if the room state is already configured to represent us being joined.
71
- * It only means that the Manager should be trying to connect or to disconnect running.
72
- * The Manager is still running right after isJoined becomes false to send the disconnect events.
73
- * @returns true if we intend to be participating in the MatrixRTC session
74
- * @deprecated This name is confusing and replaced by `isActivated()`. (Returns the same as `isActivated()`)
75
- */
76
- isJoined ( ) : boolean ;
77
- /**
78
- * If the manager is activated. This means it tries to do its job to join the call, resend state events...
79
- * It does not imply that the room state is already configured to represent being joined.
80
- * It means that the Manager tries to connect or is connected. ("the manager is still active")
81
- * Once `leave()` is called the manager is not activated anymore but still running until `leave()` resolves.
82
- * @returns `true` if we intend to be participating in the MatrixRTC session
83
- */
84
- isActivated ( ) : boolean ;
85
- /**
86
- * Get the actual connection status of the manager.
87
- */
88
- get status ( ) : Status ;
89
- /**
90
- * The current status while the manager is activated
91
- */
92
- /**
93
- * Start sending all necessary events to make this user participate in the RTC session.
94
- * @param fociPreferred the list of preferred foci to use in the joined RTC membership event.
95
- * @param fociActive the active focus to use in the joined RTC membership event.
96
- * @throws can throw if it exceeds a configured maximum retry.
97
- */
98
- join ( fociPreferred : Focus [ ] , fociActive ?: Focus , onError ?: ( error : unknown ) => void ) : void ;
99
- /**
100
- * Send all necessary events to make this user leave the RTC session.
101
- * @param timeout the maximum duration in ms until the promise is forced to resolve.
102
- * @returns It resolves with true in case the leave was sent successfully.
103
- * It resolves with false in case we hit the timeout before sending successfully.
104
- */
105
- leave ( timeout ?: number ) : Promise < boolean > ;
106
- /**
107
- * Call this if the MatrixRTC session members have changed.
108
- */
109
- onRTCSessionMemberUpdate ( memberships : CallMembership [ ] ) : Promise < void > ;
110
- /**
111
- * The used active focus in the currently joined session.
112
- * @returns the used active focus in the currently joined session or undefined if not joined.
113
- */
114
- getActiveFocus ( ) : Focus | undefined ;
54
+ export type Statistics = {
55
+ counters : {
56
+ /**
57
+ * The number of times we have sent a room event containing encryption keys.
58
+ */
59
+ roomEventEncryptionKeysSent : number ;
60
+ /**
61
+ * The number of times we have received a room event containing encryption keys.
62
+ */
63
+ roomEventEncryptionKeysReceived : number ;
64
+ } ;
65
+ totals : {
66
+ /**
67
+ * The total age (in milliseconds) of all room events containing encryption keys that we have received.
68
+ * We track the total age so that we can later calculate the average age of all keys received.
69
+ */
70
+ roomEventEncryptionKeysReceivedTotalAge : number ;
71
+ } ;
72
+ } ;
115
73
116
- // TypedEventEmitter methods:
117
- on ( event : MembershipManagerEvent . StatusChanged , listener : ( oldStatus : Status , newStatus : Status ) => void ) : this;
118
- off ( event : MembershipManagerEvent . StatusChanged , listener : ( oldStatus : Status , newStatus : Status ) => void ) : this;
119
- }
74
+ export const isMyMembership = ( m : CallMembership , userId : string , deviceId : string ) : boolean =>
75
+ m . sender === userId && m . deviceId === deviceId ;
0 commit comments