Let agents show and drive Page view tabs on the iPhone
This commit is contained in:
@@ -33,6 +33,7 @@ type Client struct {
|
||||
Login string
|
||||
Host string
|
||||
Commit string
|
||||
Device string
|
||||
ConnectedAt time.Time
|
||||
LastActionAt *time.Time
|
||||
Sync *api.ClientSync
|
||||
@@ -109,7 +110,7 @@ func (r *Registry) Synced(id, login, host, commit string, sync api.ClientSync) {
|
||||
r.entry(id, login, host, commit, time.Now()).Sync = &sync
|
||||
}
|
||||
|
||||
func (r *Registry) Serve(ctx context.Context, ws *websocket.Conn, id, login, host, commit string) {
|
||||
func (r *Registry) Serve(ctx context.Context, ws *websocket.Conn, id, login, host, commit, device string) {
|
||||
ws.SetReadLimit(readLimit)
|
||||
c := &conn{ws: ws, done: make(chan struct{}), pending: map[string]chan api.ClientReply{}}
|
||||
|
||||
@@ -118,12 +119,13 @@ func (r *Registry) Serve(ctx context.Context, ws *websocket.Conn, id, login, hos
|
||||
e := r.entry(id, login, host, commit, now)
|
||||
old := e.conn
|
||||
e.conn = c
|
||||
e.Device = device
|
||||
e.ConnectedAt = now
|
||||
r.mu.Unlock()
|
||||
if old != nil {
|
||||
old.ws.Close(websocket.StatusGoingAway, "replaced by a newer connection from this client")
|
||||
}
|
||||
slog.Info("client connected", "id", id, "host", host, "login", login, "commit", commit)
|
||||
slog.Info("client connected", "id", id, "host", host, "device", device, "login", login, "commit", commit)
|
||||
r.changed()
|
||||
|
||||
defer func() {
|
||||
@@ -219,6 +221,16 @@ func (r *Registry) Recent() []Client {
|
||||
return rows
|
||||
}
|
||||
|
||||
func (r *Registry) RecentMacs() []Client {
|
||||
out := []Client{}
|
||||
for _, c := range r.Recent() {
|
||||
if c.Device == "Mac" {
|
||||
out = append(out, c)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (r *Registry) Call(ctx context.Context, name string, req api.ClientRequest) (api.ClientReply, error) {
|
||||
r.mu.Lock()
|
||||
matches := []entry{}
|
||||
|
||||
Reference in New Issue
Block a user