refactor(collab): remove live document collaboration and enforce strictly read-only sharing
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m2s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m2s
This commit is contained in:
1 parent
aea05e868a
commit
04fa774d10
16 files changed
+179
-3556
No files matched your search
+2
-507
@@ -84,37 +84,6 @@ func (c *SSEClient) trySend(data []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
type docLockItem struct {
|
||||
docID string
|
||||
userID string
|
||||
userName string
|
||||
lockedAt time.Time
|
||||
expiresAt time.Time
|
||||
}
|
||||
|
||||
type blockLockItem struct {
|
||||
docID string
|
||||
blockID string
|
||||
userID string
|
||||
userName string
|
||||
userColor string
|
||||
lockedAt time.Time
|
||||
expiresAt time.Time
|
||||
}
|
||||
|
||||
type liveSessionItem struct {
|
||||
docID string
|
||||
initiatorID string
|
||||
initiatorName string
|
||||
startedAt time.Time
|
||||
expiresAt time.Time
|
||||
}
|
||||
|
||||
type DocStore interface {
|
||||
LoadDocumentState(docID string) (string, []domain.DocumentBlock, error)
|
||||
FlushDocumentState(docID string, title string, blocks []domain.DocumentBlock) error
|
||||
}
|
||||
|
||||
type Hub struct {
|
||||
mu sync.RWMutex
|
||||
rooms map[string]map[*Client]bool
|
||||
@@ -123,37 +92,18 @@ type Hub struct {
|
||||
sseClients map[*SSEClient]bool
|
||||
sseUserRooms map[string]map[*SSEClient]bool
|
||||
sseRooms map[string]map[*SSEClient]bool
|
||||
locks map[string]*docLockItem
|
||||
blockLocks map[string]*blockLockItem // key: docID + ":" + blockID
|
||||
liveSessions map[string]*liveSessionItem // key: docID
|
||||
docRooms map[string]*DocRoom
|
||||
docStore DocStore
|
||||
stopCleanup chan struct{}
|
||||
closed bool
|
||||
}
|
||||
|
||||
func NewHub() *Hub {
|
||||
h := &Hub{
|
||||
return &Hub{
|
||||
rooms: make(map[string]map[*Client]bool),
|
||||
userRooms: make(map[string]map[*Client]bool),
|
||||
allClients: make(map[*Client]bool),
|
||||
sseClients: make(map[*SSEClient]bool),
|
||||
sseUserRooms: make(map[string]map[*SSEClient]bool),
|
||||
sseRooms: make(map[string]map[*SSEClient]bool),
|
||||
locks: make(map[string]*docLockItem),
|
||||
blockLocks: make(map[string]*blockLockItem),
|
||||
liveSessions: make(map[string]*liveSessionItem),
|
||||
docRooms: make(map[string]*DocRoom),
|
||||
stopCleanup: make(chan struct{}),
|
||||
}
|
||||
go h.cleanupLocksLoop()
|
||||
return h
|
||||
}
|
||||
|
||||
func (h *Hub) SetDocStore(store DocStore) {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
h.docStore = store
|
||||
}
|
||||
|
||||
func (h *Hub) Register(c *Client) {
|
||||
@@ -193,7 +143,6 @@ func (h *Hub) Unregister(c *Client) {
|
||||
}
|
||||
}
|
||||
|
||||
var docRoomsLeft []string
|
||||
if c.subscribedRooms != nil {
|
||||
for rID := range c.subscribedRooms {
|
||||
if room, ok := h.rooms[rID]; ok {
|
||||
@@ -202,52 +151,19 @@ func (h *Hub) Unregister(c *Client) {
|
||||
delete(h.rooms, rID)
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(rID, "doc:") {
|
||||
docRoomsLeft = append(docRoomsLeft, strings.TrimPrefix(rID, "doc:"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
userRemaining := 0
|
||||
if c.userID != "" && c.userID != "anonymous" {
|
||||
if uRoom, ok := h.userRooms[c.userID]; ok {
|
||||
delete(uRoom, c)
|
||||
userRemaining += len(uRoom)
|
||||
if len(uRoom) == 0 {
|
||||
delete(h.userRooms, c.userID)
|
||||
}
|
||||
}
|
||||
if sseRoom, ok := h.sseUserRooms[c.userID]; ok {
|
||||
userRemaining += len(sseRoom)
|
||||
}
|
||||
}
|
||||
c.closeSend()
|
||||
|
||||
// If this user has no other active client connections, release their document locks
|
||||
var releasedDocIDs []string
|
||||
if userRemaining == 0 && c.userID != "" {
|
||||
now := time.Now()
|
||||
for docID, l := range h.locks {
|
||||
if l.userID == c.userID || l.expiresAt.Before(now) {
|
||||
releasedDocIDs = append(releasedDocIDs, docID)
|
||||
delete(h.locks, docID)
|
||||
}
|
||||
}
|
||||
}
|
||||
h.mu.Unlock()
|
||||
|
||||
// Broadcast unlock events for released locks
|
||||
for _, docID := range releasedDocIDs {
|
||||
h.BroadcastToAll("DOC_UNLOCKED", map[string]string{"docId": docID, "doc_id": docID})
|
||||
}
|
||||
|
||||
// Broadcast awareness leave for doc rooms
|
||||
for _, docID := range docRoomsLeft {
|
||||
h.BroadcastRoom("doc:"+docID, "CRDT_AWARENESS_LEAVE", map[string]interface{}{
|
||||
"docId": docID,
|
||||
"userId": c.userID,
|
||||
}, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Hub) RegisterSSE(c *SSEClient) {
|
||||
@@ -294,7 +210,6 @@ func (h *Hub) UnregisterSSE(c *SSEClient) {
|
||||
}
|
||||
}
|
||||
}
|
||||
var docRoomsLeft []string
|
||||
if c.subscribedRooms != nil {
|
||||
for rID := range c.subscribedRooms {
|
||||
if room, ok := h.sseRooms[rID]; ok {
|
||||
@@ -303,48 +218,18 @@ func (h *Hub) UnregisterSSE(c *SSEClient) {
|
||||
delete(h.sseRooms, rID)
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(rID, "doc:") {
|
||||
docRoomsLeft = append(docRoomsLeft, strings.TrimPrefix(rID, "doc:"))
|
||||
}
|
||||
}
|
||||
}
|
||||
userRemaining := 0
|
||||
if c.userID != "" && c.userID != "anonymous" {
|
||||
if uRoom, ok := h.sseUserRooms[c.userID]; ok {
|
||||
delete(uRoom, c)
|
||||
userRemaining += len(uRoom)
|
||||
if len(uRoom) == 0 {
|
||||
delete(h.sseUserRooms, c.userID)
|
||||
}
|
||||
}
|
||||
if wsRoom, ok := h.userRooms[c.userID]; ok {
|
||||
userRemaining += len(wsRoom)
|
||||
}
|
||||
}
|
||||
c.closeSend()
|
||||
|
||||
var releasedDocIDs []string
|
||||
if userRemaining == 0 && c.userID != "" {
|
||||
now := time.Now()
|
||||
for docID, l := range h.locks {
|
||||
if l.userID == c.userID || l.expiresAt.Before(now) {
|
||||
releasedDocIDs = append(releasedDocIDs, docID)
|
||||
delete(h.locks, docID)
|
||||
}
|
||||
}
|
||||
}
|
||||
h.mu.Unlock()
|
||||
|
||||
for _, docID := range releasedDocIDs {
|
||||
h.BroadcastToAll("DOC_UNLOCKED", map[string]string{"docId": docID, "doc_id": docID})
|
||||
}
|
||||
|
||||
for _, docID := range docRoomsLeft {
|
||||
h.BroadcastRoom("doc:"+docID, "CRDT_AWARENESS_LEAVE", map[string]interface{}{
|
||||
"docId": docID,
|
||||
"userId": c.userID,
|
||||
}, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Hub) JoinSSERoomByID(sseID, roomID string) bool {
|
||||
@@ -386,354 +271,9 @@ func (h *Hub) LeaveSSERoomByID(sseID, roomID string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Document Locking Methods
|
||||
|
||||
func (h *Hub) AcquireDocLock(docID, userID, userName string, ttl time.Duration) (*domain.DocLockInfo, bool, *domain.DocLockInfo) {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
|
||||
now := time.Now()
|
||||
existing, exists := h.locks[docID]
|
||||
if exists && existing.expiresAt.After(now) {
|
||||
if existing.userID != userID {
|
||||
// Locked by another user
|
||||
info := &domain.DocLockInfo{
|
||||
DocID: existing.docID,
|
||||
UserID: existing.userID,
|
||||
UserName: existing.userName,
|
||||
ExpiresAt: existing.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return nil, false, info
|
||||
}
|
||||
// Same user extending lock
|
||||
existing.expiresAt = now.Add(ttl)
|
||||
if userName != "" {
|
||||
existing.userName = userName
|
||||
}
|
||||
info := &domain.DocLockInfo{
|
||||
DocID: existing.docID,
|
||||
UserID: existing.userID,
|
||||
UserName: existing.userName,
|
||||
ExpiresAt: existing.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return info, true, nil
|
||||
}
|
||||
|
||||
// Create fresh lock
|
||||
item := &docLockItem{
|
||||
docID: docID,
|
||||
userID: userID,
|
||||
userName: userName,
|
||||
lockedAt: now,
|
||||
expiresAt: now.Add(ttl),
|
||||
}
|
||||
h.locks[docID] = item
|
||||
info := &domain.DocLockInfo{
|
||||
DocID: item.docID,
|
||||
UserID: item.userID,
|
||||
UserName: item.userName,
|
||||
ExpiresAt: item.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return info, true, nil
|
||||
}
|
||||
|
||||
func (h *Hub) HeartbeatDocLock(docID, userID string, ttl time.Duration) bool {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
|
||||
now := time.Now()
|
||||
item, ok := h.locks[docID]
|
||||
if !ok || item.userID != userID || item.expiresAt.Before(now) {
|
||||
return false
|
||||
}
|
||||
item.expiresAt = now.Add(ttl)
|
||||
return true
|
||||
}
|
||||
|
||||
func (h *Hub) ReleaseDocLock(docID, userID string, isAdmin bool) bool {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
|
||||
item, ok := h.locks[docID]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if item.userID == userID || isAdmin || userID == "admin" {
|
||||
delete(h.locks, docID)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (h *Hub) GetDocLock(docID string) *domain.DocLockInfo {
|
||||
h.mu.RLock()
|
||||
defer h.mu.RUnlock()
|
||||
|
||||
item, ok := h.locks[docID]
|
||||
if !ok || item.expiresAt.Before(time.Now()) {
|
||||
return nil
|
||||
}
|
||||
return &domain.DocLockInfo{
|
||||
DocID: item.docID,
|
||||
UserID: item.userID,
|
||||
UserName: item.userName,
|
||||
ExpiresAt: item.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
}
|
||||
|
||||
// Block Locking Methods (Option B)
|
||||
|
||||
func (h *Hub) AcquireBlockLock(docID, blockID, userID, userName, userColor string, ttl time.Duration) (*domain.BlockLockInfo, bool, *domain.BlockLockInfo) {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
|
||||
now := time.Now()
|
||||
key := docID + ":" + blockID
|
||||
existing, exists := h.blockLocks[key]
|
||||
if exists && existing.expiresAt.After(now) {
|
||||
if existing.userID != userID {
|
||||
info := &domain.BlockLockInfo{
|
||||
DocID: existing.docID,
|
||||
BlockID: existing.blockID,
|
||||
UserID: existing.userID,
|
||||
UserName: existing.userName,
|
||||
UserColor: existing.userColor,
|
||||
ExpiresAt: existing.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return nil, false, info
|
||||
}
|
||||
// Refresh lease
|
||||
existing.expiresAt = now.Add(ttl)
|
||||
if userName != "" {
|
||||
existing.userName = userName
|
||||
}
|
||||
if userColor != "" {
|
||||
existing.userColor = userColor
|
||||
}
|
||||
info := &domain.BlockLockInfo{
|
||||
DocID: existing.docID,
|
||||
BlockID: existing.blockID,
|
||||
UserID: existing.userID,
|
||||
UserName: existing.userName,
|
||||
UserColor: existing.userColor,
|
||||
ExpiresAt: existing.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return info, true, nil
|
||||
}
|
||||
|
||||
item := &blockLockItem{
|
||||
docID: docID,
|
||||
blockID: blockID,
|
||||
userID: userID,
|
||||
userName: userName,
|
||||
userColor: userColor,
|
||||
lockedAt: now,
|
||||
expiresAt: now.Add(ttl),
|
||||
}
|
||||
h.blockLocks[key] = item
|
||||
info := &domain.BlockLockInfo{
|
||||
DocID: item.docID,
|
||||
BlockID: item.blockID,
|
||||
UserID: item.userID,
|
||||
UserName: item.userName,
|
||||
UserColor: item.userColor,
|
||||
ExpiresAt: item.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return info, true, nil
|
||||
}
|
||||
|
||||
func (h *Hub) ReleaseBlockLock(docID, blockID, userID string) bool {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
|
||||
key := docID + ":" + blockID
|
||||
existing, exists := h.blockLocks[key]
|
||||
if !exists {
|
||||
return false
|
||||
}
|
||||
if userID != "" && existing.userID != userID && userID != "admin" {
|
||||
return false
|
||||
}
|
||||
delete(h.blockLocks, key)
|
||||
return true
|
||||
}
|
||||
|
||||
func (h *Hub) GetDocBlockLocks(docID string) []domain.BlockLockInfo {
|
||||
h.mu.RLock()
|
||||
defer h.mu.RUnlock()
|
||||
|
||||
now := time.Now()
|
||||
var result []domain.BlockLockInfo
|
||||
prefix := docID + ":"
|
||||
for k, l := range h.blockLocks {
|
||||
if strings.HasPrefix(k, prefix) && l.expiresAt.After(now) {
|
||||
result = append(result, domain.BlockLockInfo{
|
||||
DocID: l.docID,
|
||||
BlockID: l.blockID,
|
||||
UserID: l.userID,
|
||||
UserName: l.userName,
|
||||
UserColor: l.userColor,
|
||||
ExpiresAt: l.expiresAt.Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Live Session Methods (Opt-In Live Collaboration)
|
||||
|
||||
func (h *Hub) StartLiveSession(docID, userID, userName string, ttl time.Duration) (*domain.LiveSessionInfo, bool, *domain.LiveSessionInfo) {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
|
||||
now := time.Now()
|
||||
existing, exists := h.liveSessions[docID]
|
||||
if exists && existing.expiresAt.After(now) {
|
||||
if existing.initiatorID != userID {
|
||||
info := &domain.LiveSessionInfo{
|
||||
DocID: existing.docID,
|
||||
InitiatorID: existing.initiatorID,
|
||||
InitiatorName: existing.initiatorName,
|
||||
StartedAt: existing.startedAt.Format(time.RFC3339),
|
||||
ExpiresAt: existing.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return nil, false, info
|
||||
}
|
||||
// Refresh lease
|
||||
existing.expiresAt = now.Add(ttl)
|
||||
info := &domain.LiveSessionInfo{
|
||||
DocID: existing.docID,
|
||||
InitiatorID: existing.initiatorID,
|
||||
InitiatorName: existing.initiatorName,
|
||||
StartedAt: existing.startedAt.Format(time.RFC3339),
|
||||
ExpiresAt: existing.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return info, true, nil
|
||||
}
|
||||
|
||||
item := &liveSessionItem{
|
||||
docID: docID,
|
||||
initiatorID: userID,
|
||||
initiatorName: userName,
|
||||
startedAt: now,
|
||||
expiresAt: now.Add(ttl),
|
||||
}
|
||||
h.liveSessions[docID] = item
|
||||
info := &domain.LiveSessionInfo{
|
||||
DocID: item.docID,
|
||||
InitiatorID: item.initiatorID,
|
||||
InitiatorName: item.initiatorName,
|
||||
StartedAt: item.startedAt.Format(time.RFC3339),
|
||||
ExpiresAt: item.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
return info, true, nil
|
||||
}
|
||||
|
||||
func (h *Hub) EndLiveSession(docID, userID string) bool {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
|
||||
existing, exists := h.liveSessions[docID]
|
||||
if !exists {
|
||||
return false
|
||||
}
|
||||
if userID != "" && existing.initiatorID != userID && userID != "admin" {
|
||||
return false
|
||||
}
|
||||
delete(h.liveSessions, docID)
|
||||
return true
|
||||
}
|
||||
|
||||
func (h *Hub) ForceEndLiveSession(docID string) bool {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
|
||||
if _, exists := h.liveSessions[docID]; !exists {
|
||||
return false
|
||||
}
|
||||
delete(h.liveSessions, docID)
|
||||
return true
|
||||
}
|
||||
|
||||
func (h *Hub) GetLiveSession(docID string) *domain.LiveSessionInfo {
|
||||
h.mu.RLock()
|
||||
defer h.mu.RUnlock()
|
||||
|
||||
now := time.Now()
|
||||
existing, exists := h.liveSessions[docID]
|
||||
if !exists || existing.expiresAt.Before(now) {
|
||||
return nil
|
||||
}
|
||||
return &domain.LiveSessionInfo{
|
||||
DocID: existing.docID,
|
||||
InitiatorID: existing.initiatorID,
|
||||
InitiatorName: existing.initiatorName,
|
||||
StartedAt: existing.startedAt.Format(time.RFC3339),
|
||||
ExpiresAt: existing.expiresAt.Format(time.RFC3339),
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Hub) cleanupLocksLoop() {
|
||||
ticker := time.NewTicker(2 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-h.stopCleanup:
|
||||
return
|
||||
case <-ticker.C:
|
||||
h.mu.Lock()
|
||||
now := time.Now()
|
||||
|
||||
var expiredDocIDs []string
|
||||
for docID, l := range h.locks {
|
||||
if l.expiresAt.Before(now) {
|
||||
expiredDocIDs = append(expiredDocIDs, docID)
|
||||
delete(h.locks, docID)
|
||||
}
|
||||
}
|
||||
|
||||
type expBlock struct {
|
||||
docID string
|
||||
blockID string
|
||||
}
|
||||
var expiredBlocks []expBlock
|
||||
for k, bl := range h.blockLocks {
|
||||
if bl.expiresAt.Before(now) {
|
||||
expiredBlocks = append(expiredBlocks, expBlock{docID: bl.docID, blockID: bl.blockID})
|
||||
delete(h.blockLocks, k)
|
||||
}
|
||||
}
|
||||
|
||||
var expiredLiveSessions []string
|
||||
for docID, ls := range h.liveSessions {
|
||||
if ls.expiresAt.Before(now) {
|
||||
expiredLiveSessions = append(expiredLiveSessions, docID)
|
||||
delete(h.liveSessions, docID)
|
||||
}
|
||||
}
|
||||
h.mu.Unlock()
|
||||
|
||||
for _, docID := range expiredDocIDs {
|
||||
h.BroadcastToAll("DOC_UNLOCKED", map[string]string{"docId": docID, "doc_id": docID})
|
||||
}
|
||||
for _, b := range expiredBlocks {
|
||||
h.BroadcastRoom("doc:"+b.docID, "DOC_BLOCK_UNLOCKED", map[string]string{
|
||||
"docId": b.docID,
|
||||
"blockId": b.blockID,
|
||||
}, nil)
|
||||
}
|
||||
for _, docID := range expiredLiveSessions {
|
||||
h.BroadcastRoom("doc:"+docID, "DOC_LIVE_ENDED", map[string]string{
|
||||
"docId": docID,
|
||||
}, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Close gracefully shuts down the Hub, stops background tickers, flushes dirty document rooms to DB,
|
||||
// and immediately disconnects all WebSocket and SSE connections so HTTP shutdown completes in milliseconds.
|
||||
// Close gracefully disconnects all WebSocket and SSE connections so HTTP shutdown completes immediately.
|
||||
func (h *Hub) Close() {
|
||||
h.mu.Lock()
|
||||
if h.closed {
|
||||
@@ -742,19 +282,6 @@ func (h *Hub) Close() {
|
||||
}
|
||||
h.closed = true
|
||||
|
||||
if h.stopCleanup != nil {
|
||||
select {
|
||||
case <-h.stopCleanup:
|
||||
default:
|
||||
close(h.stopCleanup)
|
||||
}
|
||||
}
|
||||
|
||||
docRooms := make([]*DocRoom, 0, len(h.docRooms))
|
||||
for _, r := range h.docRooms {
|
||||
docRooms = append(docRooms, r)
|
||||
}
|
||||
|
||||
allWsClients := make([]*Client, 0, len(h.allClients))
|
||||
for c := range h.allClients {
|
||||
allWsClients = append(allWsClients, c)
|
||||
@@ -766,28 +293,11 @@ func (h *Hub) Close() {
|
||||
}
|
||||
h.mu.Unlock()
|
||||
|
||||
// 1. Flush any active dirty document rooms and close doc WS connections
|
||||
for _, r := range docRooms {
|
||||
r.Flush()
|
||||
r.mu.Lock()
|
||||
if r.debounceTimer != nil {
|
||||
r.debounceTimer.Stop()
|
||||
r.debounceTimer = nil
|
||||
}
|
||||
for c := range r.wsClients {
|
||||
_ = c.conn.Close()
|
||||
}
|
||||
r.wsClients = make(map[*DocWSClient]bool)
|
||||
r.mu.Unlock()
|
||||
}
|
||||
|
||||
// 2. Close all WebSocket connections
|
||||
for _, c := range allWsClients {
|
||||
_ = c.conn.Close()
|
||||
c.closeSend()
|
||||
}
|
||||
|
||||
// 3. Close all SSE client channels so ServeSSE select loop exits immediately
|
||||
for _, c := range allSSEClients {
|
||||
c.closeSend()
|
||||
}
|
||||
@@ -1116,21 +626,6 @@ func (c *Client) readPump() {
|
||||
c.hub.LeaveRoom(c, room)
|
||||
}
|
||||
}
|
||||
|
||||
if docID != "" {
|
||||
switch incoming.Event {
|
||||
case "LOCK_DOC":
|
||||
if info, ok, _ := c.hub.AcquireDocLock(docID, c.userID, "", 30*time.Second); ok && info != nil {
|
||||
c.hub.BroadcastDocEvent(docID, "DOC_LOCKED", info)
|
||||
}
|
||||
case "HEARTBEAT_DOC":
|
||||
c.hub.HeartbeatDocLock(docID, c.userID, 30*time.Second)
|
||||
case "UNLOCK_DOC":
|
||||
if c.hub.ReleaseDocLock(docID, c.userID, false) {
|
||||
c.hub.BroadcastDocEvent(docID, "DOC_UNLOCKED", map[string]string{"docId": docID, "doc_id": docID})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user