Sync open chats across devices through the server (pipeline run work in progress)
This commit is contained in:
@@ -62,6 +62,22 @@ func (c *chatSessionChanges) broadcast(sender string, session protocol.ChatSessi
|
||||
}
|
||||
}
|
||||
|
||||
func (c *chatSessionChanges) broadcastWorkspace(sender string, snapshot protocol.ChatOpenWorkspaceSnapshot) {
|
||||
c.mu.Lock()
|
||||
targets := make([]func(protocol.Message) error, 0, len(c.clients))
|
||||
for id, write := range c.clients {
|
||||
if id != sender {
|
||||
targets = append(targets, write)
|
||||
}
|
||||
}
|
||||
c.mu.Unlock()
|
||||
for _, write := range targets {
|
||||
copy := snapshot
|
||||
copy.Entries = append([]protocol.ChatOpenWorkspaceEntry(nil), snapshot.Entries...)
|
||||
go func() { _ = write(protocol.Message{Type: protocol.ChatOpenWorkspaceChanged, ChatOpenWorkspace: ©}) }()
|
||||
}
|
||||
}
|
||||
|
||||
// echoOperatorSession answers a metadata change with the updated registry row
|
||||
// and pushes the same row to every other connection.
|
||||
func echoOperatorSession(ctx context.Context, request protocol.Message, sessionID, reply string, registry operatorRegistry, changes *chatSessionChanges, clientID string, write func(protocol.Message) error) {
|
||||
|
||||
Reference in New Issue
Block a user