Skip to content

Enhance WebSocket collaboration handler and hub management#9

Merged
moutonjeremy merged 2 commits intomainfrom
collaboration
Apr 19, 2026
Merged

Enhance WebSocket collaboration handler and hub management#9
moutonjeremy merged 2 commits intomainfrom
collaboration

Conversation

@moutonjeremy
Copy link
Copy Markdown
Member

This pull request introduces a new WebSocket-based collaboration backend, enabling real-time Y.js document synchronization. The implementation adds a scalable, room-based relay system for binary collaboration messages, integrates authentication via JWT tokens, and ensures proper resource management. It also updates the dependency injection and server/router setup to support the new collaboration feature.

New Collaboration WebSocket Backend

  • Added a new collaboration module with the following components:
    • handler.go: Handles WebSocket upgrades, authenticates users via JWT, and manages WebSocket connections for Y.js rooms.
    • hub.go: Manages the lifecycle of collaboration rooms, including creation, removal, and statistics.
    • room.go: Implements room logic, client management, and message broadcasting between clients (pure relay for binary Y.js messages).

Dependency Injection and Server Initialization

  • Registered the new CollaborationHub in the dependency injection container and initialized it during server startup. [1] [2]

HTTP Routing and Middleware Integration

  • Registered new WebSocket routes under /ws/collab/:roomId, including JWT authentication middleware and route setup in the HTTP router.
  • Updated static file serving logic to skip WebSocket routes, ensuring proper handling of SPA and WebSocket endpoints.

Dependency Updates

  • Added new dependencies for WebSocket support and utilities in go.mod (github.com/gofiber/websocket/v2, github.com/fasthttp/websocket, github.com/savsgio/gotils). [1] [2]

Codebase Integration

  • Updated imports in relevant files to integrate the new collaboration package. [1] [2] [3]

This change lays the foundation for real-time collaborative editing features using Y.js and WebSockets, with robust authentication and room management.

@moutonjeremy moutonjeremy merged commit 6785a64 into main Apr 19, 2026
1 check passed
@moutonjeremy moutonjeremy deleted the collaboration branch April 19, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant