Room class

Represents a SDN room.

Available extensions

Constructors

Room({required String id, Membership membership = Membership.join, int notificationCount = 0, int highlightCount = 0, String? prev_batch, required Client client, String? notificationSettings, Map<String, BasicRoomEvent>? roomAccountData, RoomSummary? summary})
Room.fromJson(Map<String, dynamic> json, Client client)
factory

Properties

avatar Uri?
The avatar of the room if set by a participant.
no setter
canBan bool
The level required to ban a user.
no setter
canChangeGuestAccess bool
Whether the user has the permission to change the guest access.
no setter
canChangeHistoryVisibility bool
Whether the user has the permission to change the history visibility.
no setter
canChangeJoinRules bool
Whether the user has the permission to change the join rules.
no setter
canChangePowerLevel bool
no setter
canCreateGroupCall bool
no setter
canInvite bool
The level required to invite a user.
no setter
canJoinGroupCall bool
no setter
canKick bool
The level required to kick a user.
no setter
canonicalAlias String
The address in the format: #roomname:node.org.
no setter
canRedact bool
The level required to redact an event.
no setter
canSendDefaultMessages bool
The default level required to send message events. Can be overridden by the events key.
no setter
canSendDefaultStates bool
The default level required to send state events. Can be overridden by the events key.
no setter
client Client
Your current client instance.
final
directChatSDNID String?
If this room is a direct chat, this is the sdn ID of the user. Returns null otherwise.
no setter
displayname String
Calculates the displayname. First checks if there is a name, then checks for a canonical alias and then generates a name from the heroes.
no setter
encrypted bool
Checks if this room is encrypted.
no setter
encryptionAlgorithm String?
Returns the encryption algorithm. Currently only m.megolm.v1.aes-sha2 is supported. Returns null if there is no encryption algorithm.
no setter
ephemerals Map<String, BasicRoomEvent>
Key-Value store for ephemerals.
getter/setter pair
extinctInformations TombstoneContent?
Returns informations about how this room is
no setter
fullyRead String
ID of the fully read marker event.
no setter
groupCallsEnabled bool
if returned value is not null org.sdn.msc3401.call.member is present and group calls can be used
no setter
guestAccess GuestAccess
This event controls whether guest users are allowed to join rooms. If this event is absent, servers should act as if it is present and has the guest_access value "forbidden".
no setter
hashCode int
The hash code for this object.
no setteroverride
hasNewMessages bool
Checks if the last event has a read marker of the user. Warning: This compares the origin server timestamp which might not map to the real sort order of the timeline.
no setter
highlightCount int
The count of highlighted notifications.
getter/setter pair
historyVisibility HistoryVisibility?
This event controls whether a user can see the events that happened in a room from before they joined.
no setter
id String
The full qualified SDN ID for the room in the format '!localid:server.abc'.
final
isAbandonedDMRoom bool
Checks if this is an abandoned DM room where the other participant has left the room. This is false when there are still other users in the room or the room is not marked as a DM room.
no setter
isArchived bool
Is the room archived
no setter
isDirectChat bool
Wheither this is a direct chat or not
no setter
isExtinct bool
Whether this is an extinct room which has been archived in favor of a new room which replaces this. Use getLegacyRoomInformations() to get more informations about it if this is true.
no setter
isFavourite bool
Returns true if this room has a m.favourite tag.
no setter
isSpace bool
Checks if the m.room.create state has a type key with the value m.space.
no setter
isUnread bool
Returns true if this room is unread. To check if there are new messages in muted rooms, use hasNewMessages.
no setter
isUnreadOrInvited bool
Returns true if this room is to be marked as unread. This extends isUnread to rooms with Membership.invite.
no setter
joinRules JoinRules?
A room may be public meaning anyone can join the room without any prior action. Alternatively, it can be invite meaning that a user who wishes to join the room must first receive an invite to the room from someone already inside of the room. Currently, knock and private are reserved keywords which are not implemented.
no setter
lastEvent Event?
no setter
markedUnread bool
no setter
membership Membership
Membership status of the user for this room.
getter/setter pair
name String
The name of the room if set by a participant.
no setter
notificationCount int
The count of unread notifications.
getter/setter pair
notificationSettings String?
Must be one of all, mention
getter/setter pair
onSessionKeyReceived → CachedStreamController<String>
If there is a new session key received, this will be triggered with the session ID.
final
onUpdate → CachedStreamController<String>
If something changes, this callback will be triggered. Will return the room id.
final
ownPowerLevel int
Returns the user's own power level.
no setter
partial bool
Flag if the room is partial, meaning not all state events have been loaded yet
getter/setter pair
participantListComplete bool
Checks if the local participant list of joined and invited users is complete.
no setter
pinnedEventIds List<String>
The pinned events for this room. If there are none this returns an empty list.
no setter
powerLevels Map<String, int>?
Returns the power levels from all users for this room or null if not given.
no setter
prev_batch String?
A token that can be supplied to the from parameter of the rooms/{roomId}/messages endpoint.
getter/setter pair
pushRuleState PushRuleState
Returns the PushRuleState for this room, based on the m.push_rules stored in the account_data.
no setter
receiptState LatestReceiptState
no setter
roomAccountData Map<String, BasicRoomEvent>
Key-Value store for private account data only visible for this user.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sendingFilePlaceholders Map<String, SDNFile>
final
sendingFileThumbnails Map<String, SDNImageFile>
final
spaceChildren List<SpaceChild>
List all children of this space. Children without a via domain will be ignored. Children are sorted by the order while those without this field will be sorted at the end of the list.
no setter
spaceParents List<SpaceParent>
The parents of this room. Currently this SDK doesn't yet set the canonical flag and is not checking if this room is in fact a child of this space. You should therefore not rely on this and always check the children of the space.
no setter
staleGroupCallsTimer Map<String, Timer>
stores stale group call checking timers for rooms.
getter/setter pair
states Map<String, Map<String, Event>>
The room states are a key value store of the key (type,state_key) => State(event). In a lot of cases the state_key might be an empty string. You should use the methods getState() and setState() to interact with the room states.
getter/setter pair
summary RoomSummary
getter/setter pair
tags Map<String, Tag>
Returns all tags for this room.
no setter
timeCreated DateTime
When the last message received.
no setter
topic String
The topic of the room if set by a participant.
no setter
typingUsers List<User>
Returns a list of all current typing users.
no setter
userFullyReadMarker String?
Get the user fully read marker
no setter
waitForSync Future<SyncUpdate>
no setter

Methods

addTag(String tag, {double? order}) Future<void>
Add a tag to the room.
addToDirectChat(String userID) Future<void>
Sets this room as a direct chat for this user if not already.
ban(String userID) Future<void>
Call the SDN API to ban a user from this room.
calcEncryptionHealthState() Future<EncryptionHealthState>
Calculates how secure the communication is. When all devices are blocked or verified, then this returns EncryptionHealthState.allVerified. When at least one device is not verified, then it returns EncryptionHealthState.unverifiedDevices. Apps should display this health state next to the input text field to inform the user about the current encryption security level.
canChangeStateEvent(String action) bool
returns if user can change a particular state event by comparing ownPowerLevel with possible overrides in events, if not present compares ownPowerLevel with state_default
canSendEvent(String eventType) bool
The level required to send a certain event. Defaults to 0 if there is no events_default set or there is no power level state in the room.
canSendNotification(String userid, {String notificationType = 'room'}) bool
The power level requirements for specific notification types.
enableEncryption({int algorithmIndex = 0}) Future<void>
enableGroupCalls() Future<void>
sets the org.sdn.msc3401.call.member power level to users default for group calls, needs permissions to change power levels
forget() Future<void>
Call the SDN API to forget this room if you already left it.
getDefaultPowerLevel(Map<String, dynamic> powerLevelMap) int
Takes in [m.room.power_levels].content and returns the default power level
getEventById(String eventID) Future<Event?>
Searches for the event in the local cache and then on the server if not found. Returns null if not found anywhere.
getEventContext(String eventId) Future<TimelineChunk?>
getLocalizedDisplayname([SDNLocalizations i18n = const SDNDefaultLocalizations()]) String
Returns a localized displayname for this server. If the room is a groupchat without a name, then it will return the localized version of 'Group with Alice' instead of just 'Alice' to make it different to a direct chat. Empty chats will become the localized version of 'Empty Chat'. This method requires a localization class which implements SDNLocalizations
getMention(String mention) String?
returns the resolved mxid for a mention string, or null if none found
getParticipants([List<Membership> membershipFilter = const [Membership.join, Membership.invite, Membership.knock]]) List<User>
Returns all participants for this room. With lazy loading this list may not be complete. Use requestParticipants in this case. List membershipFilter defines with what membership do you want the participants, default set to [Membership.join, Membership.invite, Membership.knock]
getPowerLevelByUserId(String userId) int
Returns the power level of the given user ID. If a user_id is in the users list, then that user_id has the associated power level. Otherwise they have the default level users_default. If users_default is not supplied, it is assumed to be 0. If the room contains no m.room.power_levels event, the room’s creator has a power level of 100, and all other users have a power level of 0.
getState(String typeKey, [String stateKey = '']) Event?
Returns the Event for the given typeKey and optional stateKey. If no stateKey is provided, it defaults to an empty string.
getTimeline({void onChange(int index)?, void onRemove(int index)?, void onInsert(int insertID)?, void onNewEvent()?, void onUpdate()?, String? eventContextId}) Future<Timeline>
Creates a timeline from the store. Returns a Timeline object. If you just want to update the whole timeline on every change, use the onUpdate callback. For updating only the parts that have changed, use the onChange, onRemove, onInsert and the onHistoryReceived callbacks. This method can also retrieve the timeline at a specific point by setting the eventContextId
getUserByMXIDSync(String mxID) User
getUserDeviceKeys() Future<List<DeviceKeys>>
Returns all known device keys for all participants in this room.
invite(String userID) Future<void>
Call the SDN API to invite a user to this room.
join({bool leaveIfNotFound = true}) Future<void>
Call the SDN API to join this room if the user is not already a member. If this room is intended to be a direct chat, the direct chat flag will automatically be set.
kick(String userID) Future<void>
Call the SDN API to kick a user from this room.
leave() Future<void>
Call the SDN API to leave this room. If this room is set as a direct chat, this will be removed too.
markUnread(bool unread) Future<void>
Sets an unread flag manually for this room. This changes the local account data model before syncing it to make sure this works if there is no connection to the node. This does not set a read marker!
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
postLoad() Future<void>
Post-loads the room. This load all the missing state events for the room from the database If the room has already been loaded, this does nothing.
postReceipt(String eventId, {ReceiptType type = ReceiptType.mRead}) Future<void>
This API updates the marker for the given receipt type to the event ID specified. In general you want to use setReadMarker instead to set private and public receipt as well as the marker at the same time.
powerForChangingStateEvent(String action) int
returns the powerlevel required for chaning the action defaults to state_default if action isn't specified in events override. If there is no state_default in the m.room.power_levels event, the state_default is 50. If the room contains no m.room.power_levels event, the state_default is 0.
redactEvent(String eventId, {String? reason, String? txid}) Future<String?>
Redacts this event. Throws ErrorResponse on error.
removeFromDirectChat() Future<void>
Removes this room from all direct chat tags.
removeSpaceChild(String roomId) Future<void>
Remove a child from this space by setting the via to an empty list.
removeTag(String tag) Future<void>
Removes a tag from the room.
requestHistory({int historyCount = defaultHistoryCount, void onHistoryReceived()?, dynamic direction = Direction.b}) Future<int>
Request more previous events from the server. historyCount defines how much events should be received maximum. When the request is answered, onHistoryReceived will be triggered before the historical events will be published in the onEvent stream. Returns the actual count of received timeline events.
requestParticipants([List<Membership> membershipFilter = const [Membership.join, Membership.invite, Membership.knock], bool suppressWarning = false]) Future<List<User>>
Request the full list of participants from the server. The local list from the store is not complete if the client uses lazy loading. List membershipFilter defines with what membership do you want the participants, default set to [Membership.join, Membership.invite, Membership.knock]
requestSessionKey(String sessionId, String senderKey) Future<void>
requestUser(String mxID, {bool ignoreErrors = false, bool requestProfile = true}) Future<User?>
Requests a missing User for this room. Important for clients using lazy loading. If the user can't be found this method tries to fetch the displayname and avatar from the profile if requestProfile is true.
Generates a sdn.to link with appropriate routing info to share the room
sendEvent(Map<String, dynamic> content, {String type = EventTypes.Message, String? txid, Event? inReplyTo, String? editEventId, String? threadRootEventId, String? threadLastEventId}) Future<String?>
Sends an event to this room with this json as a content. Returns the event ID generated from the server. It uses list of completer to make sure events are sending in a row.
sendFileEvent(SDNFile file, {String? txid, Event? inReplyTo, String? editEventId, int? shrinkImageMaxDimension, SDNImageFile? thumbnail, Map<String, dynamic>? extraContent, String? threadRootEventId, String? threadLastEventId}) Future<String?>
Sends a file to this room after uploading it. Returns the mxc uri of the uploaded file. If waitUntilSent is true, the future will wait until the message event has received the server. Otherwise the future will only wait until the file has been uploaded. Optionally specify extraContent to tack on to the event.
sendLocation(String body, String geoUri, {String? txid}) Future<String?>
Sends the location with description body and geo URI geoUri into a room. Returns the event ID generated by the server for this message.
sendReaction(String eventId, String key, {String? txid}) Future<String?>
Sends a reaction to an event with an eventId and the content key into a room. Returns the event ID generated by the server for this reaction.
sendTextEvent(String message, {String? txid, Event? inReplyTo, String? editEventId, bool parseMarkdown = true, bool parseCommands = true, String msgtype = MessageTypes.Text, String? threadRootEventId, String? threadLastEventId}) Future<String?>
Sends a normal text message to this room. Returns the event ID generated by the server for this message.
setAvatar(SDNFile? file) Future<String>
Uploads a new user avatar for this room. Returns the event ID of the new m.room.avatar event. Leave empty to remove the current avatar.
setCanonicalAlias(String canonicalAlias) Future<void>
Sets the canonical alias. If the canonicalAlias is not yet an alias of this room, it will create one.
setDescription(String newName) Future<String>
Call the SDN API to change the topic of this room.
setFavourite(bool favourite) Future<void>
Sets the m.favourite tag for this room.
setGuestAccess(GuestAccess guestAccess) Future<void>
Changes the guest access. You should check first if the user is able to change it.
setHistoryVisibility(HistoryVisibility historyVisibility) Future<void>
Changes the history visibility. You should check first if the user is able to change it.
setJoinRules(JoinRules joinRules) Future<void>
Changes the join rules. You should check first if the user is able to change it.
setName(String newName) Future<String>
Call the SDN API to change the name of this room. Returns the event ID of the new m.room.name event.
setPinnedEvents(List<String> pinnedEventIds) Future<String>
Call the SDN API to change the pinned events of this room.
setPower(String userID, int power) Future<String>
Set the power level of the user with the userID to the value power. Returns the event ID of the new state event. If there is no known power level event, there might something broken and this returns null.
setPushRuleState(PushRuleState newState) Future<void>
Sends a request to the node to set the PushRuleState for this room. Returns ErrorResponse if something goes wrong.
setReadMarker(String? eventId, {String? mRead, bool? public}) Future<void>
Sets the position of the read marker for a given room, and optionally the read receipt's location. If you set public to false, only a private receipt will be sent. A private receipt is always sent if mRead is set. If no value is provided, the default from the client is used. You can leave out the eventId, which will not update the read marker but just send receipts, but there are few cases where that makes sense.
setSpaceChild(String roomId, {List<String>? via, String? order, bool? suggested}) Future<void>
Adds or edits a child of this space.
setState(Event state) → void
Adds the state to this room and overwrites a state with the same typeKey/stateKey key pair if there is one.
setTyping(bool isTyping, {int? timeout}) Future<void>
This tells the server that the user is typing for the next N milliseconds where N is the value specified in the timeout key. Alternatively, if typing is false, it tells the server that the user has stopped typing.
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
inherited
unban(String userID) Future<void>
Call the SDN API to unban a banned user from this room.
unsafeGetUserFromMemoryOrFallback(String mxID) User
Returns the User object for the given mxID or return a fallback User and start a request to get the user from the node.
waitForRoomInSync() Future<SyncUpdate>
Wait for the room to appear in join, leave or invited section of the sync.

Operators

operator ==(dynamic other) bool
The equality operator.
override

Constants

defaultHistoryCount → const int
The default count of how much events should be requested when requesting the history of this room.