Uniform Chat
  • Uniform.Matrix
  • API
Search Results for

    Show / Hide Table of Contents
    • Uniform.Matrix.Protocol.Core
      • Introduction
    • Uniform.Matrix.Protocol.Client
      • Introduction
      • Log in
      • Receive events
      • Rooms and messages
      • Directories and account data
      • Files and devices
      • Errors
    • Uniform.Matrix.Protocol.Crypto
      • Introduction
    • Uniform.Matrix.Hosting
      • Introduction
    • Uniform.Matrix.Gui.Terminal
      • Introduction
    • Uniform.Matrix.Audio
      • Introduction
    • Uniform.Matrix.Video
      • Introduction
    • Uniform.Stun.Protocol
      • Introduction
    • Uniform.Stun
      • Introduction
    • Uniform.LiveKit.Protocol
      • Introduction
    • Uniform.LiveKit
      • Introduction
    • Uniform.Matrix.WebRtc
      • Introduction
    • Uniform.Matrix.Client
      • Introduction
      • Room state
      • Rich text
      • Local storage
      • Outbox
      • Track rooms
    • Uniform.Matrix.Calls
      • Introduction
    • Uniform.Chat.Terminal
      • Introduction
    • Uniform.Chat.Avalonia
      • Introduction
      • View models
      • Views
    • Uniform.Chat.Desktop
      • Introduction
    • Uniform.Chat.Android
      • Introduction
    • Uniform.Matrix.Protocol.Server
      • Introduction
    • Uniform.Matrix.Server
      • Introduction
      • Requests
      • Storage
      • Events and state
      • Sync and the stream
      • Services
      • Push rules and pushers
      • Presence
      • URL previews
      • Rate limits
      • Federation
      • Testing
    • Uniform.Chat.Server
      • Introduction
    • Uniform.Turn
      • Introduction
    • Uniform.Stun.Hosting
      • Introduction
    • Uniform.Stun.Server
      • Introduction
    • Uniform.LiveKit.Authorization
      • Introduction
    • Uniform.LiveKit.Hosting
      • Introduction
    • Uniform.LiveKit.Server
      • Introduction
    • Building
    • Testing
    • Documentation

    Receive events

    Filter filter = new() { Room = new RoomFilter { Timeline = new RoomEventFilter { Limit = 50, LazyLoadMembers = true } } };
    string filterId = await client.CreateFilterAsync(filter);
    
    await foreach (SyncResponse sync in client.SyncLoopAsync(filter: filterId, onRetry: (exception, wait) => Console.Error.WriteLine($"Sync failed, retrying in {wait}: {exception.Message}"), cancellationToken: cancellationToken))
    {
        foreach ((string roomId, JoinedRoom room) in sync.Rooms.Join)
        {
            foreach (ClientEvent clientEvent in room.Timeline.Events)
            {
                if (clientEvent.Type != EventTypes.RoomMessage) continue;
                if (!clientEvent.TryGetContent(out MessageContent? message)) continue;
                Console.WriteLine($"[{roomId}] {clientEvent.Sender}: {message.Body}");
            }
        }
    
        foreach ((string roomId, InvitedRoom invite) in sync.Rooms.Invite)
            Console.WriteLine($"Invited to {roomId}");
    }
    

    Store the last NextBatch together with the session and pass it as since to continue where you left off.

    When room.Timeline.Limited is true, the server skipped events. Fetch them with GetMessagesAsync starting from room.Timeline.PrevBatch.

    • Edit this page
    In this article
    Back to top Uniform Chat