Real-time collaboration (Yjs + WebSocket)
- Go WebSocket hub: rooms per document, broadcast updates, persist state - Yjs integration: connect/disconnect, sync document state - Collab toggle button in toolbar (Solo/Live) - When Live: edits broadcast to all connected users in real-time - Yjs state persisted to SQLite (survives server restart) - gorilla/websocket dependency added
This commit is contained in:
+8
-1
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"markdownhub/internal/api"
|
||||
"markdownhub/internal/auth"
|
||||
"markdownhub/internal/collab"
|
||||
"markdownhub/internal/db"
|
||||
"markdownhub/internal/files"
|
||||
)
|
||||
@@ -33,8 +34,14 @@ func main() {
|
||||
|
||||
router := api.NewRouter(database, dataDir, secret)
|
||||
|
||||
// Collab WebSocket hub
|
||||
hub := collab.NewHub(database)
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/ws/collab/", http.HandlerFunc(hub.HandleWebSocket))
|
||||
mux.Handle("/", router)
|
||||
|
||||
fmt.Printf("MarkdownHub listening on :%s\n", port)
|
||||
log.Fatal(http.ListenAndServe(":"+port, router))
|
||||
log.Fatal(http.ListenAndServe(":"+port, mux))
|
||||
}
|
||||
|
||||
func ensureAdminUser(database *db.DB, dataDir string) {
|
||||
|
||||
Reference in New Issue
Block a user