mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add sessions cursors.
This commit is contained in:
@ -132,6 +132,41 @@ func (manager *WebSocketManagerCtx) Start() {
|
||||
|
||||
manager.fileChooserDialogEvents()
|
||||
|
||||
manager.wg.Add(1)
|
||||
go func() {
|
||||
defer manager.wg.Done()
|
||||
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-manager.shutdown:
|
||||
return
|
||||
case <-ticker.C:
|
||||
cursorsMap := manager.sessions.PopCursors()
|
||||
if len(cursorsMap) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
cursors := []message.SessionCursor{}
|
||||
for session, cursor := range cursorsMap {
|
||||
cursors = append(
|
||||
cursors,
|
||||
message.SessionCursor{
|
||||
ID: session.ID(),
|
||||
X: uint16(cursor.X),
|
||||
Y: uint16(cursor.Y),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: Send to subscribers only.
|
||||
manager.sessions.AdminBroadcast(event.SESSION_CURSORS, cursors, nil)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
manager.logger.Info().Msg("websocket starting")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user