Set Up Document Collaboration with SignalR

How to bootstrap collaborative documents, connect the hub, and manage presence and text state.

Set Up Document Collaboration with SignalR

Bootstrap an existing document through the collaboration REST endpoint, connect to the returned hubPath, and call:

JoinDocument(collaborativeDocumentId)

The join evaluates the exact current credential, including live personal access token ceilings. It returns the visible editor list and adds the connection to the document group. Subscribe to the normal collaboration events before editing:

  • PresenceUpdated
  • TextStateUpdated
  • TextOperationsApplied
  • DocumentPublished
  • SubscriptionRevoked

Use UpdatePresence while the editor is active and LeaveDocument when it closes. A permission change, entitlement transition, or credential expiry can invalidate an active join. The server then removes the connection from the document group, clears its presence, broadcasts the updated editor list, and sends:

SubscriptionRevoked(collaborativeDocumentId)

After revocation, stop local editing immediately and repeat REST bootstrap before reconnecting. Do not treat a previous group join or presence entry as durable authorization.

Presence, text-state, text-operation, publish, and restore events are re-authorized immediately before delivery. PixService reloads the exact joined credential and sends only to connection IDs whose final document access still survives. This delivery check prevents a stale group membership from receiving protected collaboration payloads during asynchronous eviction.

PixService filters presence per authorized connection before grouping sessions by user. Revoked sessions do not affect editor names, profile pictures, activity/selection metadata, or connection counts, including when another session for the same user remains valid. Hub reads and writes also re-authorize the exact joined credential on every call. Fully hidden or revoked documents return the same Collaborative document not found or not accessible. error; readable but non-editable documents return the normal read-only error.

Publishing a new version preserves that exact credential through finalization. PixService selects OrganizationDocuments=Write, ClusterDocuments=Write, or LocationDocuments=Write from the document library scope and evaluates the current folder path. It reserves the actual encoded byte count before object upload, then re-evaluates the same path and tier-capped capability before one serializable transaction commits both storage usage and the new document version. A denied or stale credential, moved destination, or exhausted Document capacity attaches no version.

On this page