Typed Event Emitter class which can act as a Base Model for all our model and communication events. This makes it much easier for us to distinguish between events, as we now need to properly type this, so that our events are not stringly-based and prone to silly typos.

Type parameters:

  • Events - List of all events emitted by this TypedEventEmitter. Normally an enum type.
  • Arguments - A ListenerMap type providing mappings from event names to listener types.
  • SuperclassArguments - TODO: not really sure. Alternative listener mappings, I think? But only honoured for .emit?

Hierarchy (View Summary)

Constructors

  • Construct a new User. A User must have an ID and can optionally have extra information associated with it.

    Parameters

    • userId: string

      Required. The ID of this user.

    Returns User

    use User.createUser

Properties

avatarUrl?: string

The 'avatar_url' of the user if known.

currentlyActive: boolean = false

Whether we should consider lastActiveAgo to be an approximation and that the user should be seen as active 'now'

displayName?: string

The 'displayname' of the user if known.

events: { presence?: MatrixEvent; profile?: MatrixEvent } = {}

The events describing this user.

Type declaration

lastActiveAgo: number = 0

Timestamp (ms since the epoch) for when we last received presence data for this user. We can subtract lastActiveAgo from this to approximate an absolute value for when a user was last active.

lastPresenceTs: number = 0

The time elapsed in ms since the user interacted proactively with the server, or we saw a message from the user

presence: string = "offline"

The presence enum if known.

presenceStatusMsg?: string

The presence status message if known.

rawDisplayName?: string
userId: string

Required. The ID of this user.

Methods

  • Get the absolute timestamp when this User was last known active on the server. It is NOT accurate if this.currentlyActive is true.

    Returns number

    The timestamp

  • Get the timestamp when this User was last updated. This timestamp is updated when this User receives a new Presence event which has updated a property on this object. It is updated before firing events.

    Returns number

    The timestamp

  • Manually set this user's avatar URL. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.

    Parameters

    • Optionalurl: string

      The new avatar URL.

    Returns void

  • Manually set this user's display name. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.

    Parameters

    • name: string

      The new display name.

    Returns void

  • Manually set this user's non-disambiguated display name. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.

    Parameters

    • Optionalname: string

      The new display name.

    Returns void

  • Construct a new User whose events will also emit on MatrixClient. A User must have an ID and can optionally have extra information associated with it.

    Parameters

    • userId: string

      Required. The ID of this user.

    • client: MatrixClient

      An instance of MatrixClient object

    Returns User

    User object with reEmitter setup on client