| 656 | const clientActionTimeout = 30 * time.Second |
| 657 | |
| 658 | func (h *Handler) handleClientStart(w http.ResponseWriter, r *http.Request, accountID types.AccountID) { |
| 659 | client, ok := h.provider.GetClient(accountID) |
| 660 | if !ok { |
| 661 | h.writeJSON(w, map[string]any{"error": "client not found"}) |
| 662 | return |
| 663 | } |
| 664 | |
| 665 | ctx, cancel := context.WithTimeout(r.Context(), clientActionTimeout) |
| 666 | defer cancel() |
| 667 | |
| 668 | if err := client.Start(ctx); err != nil { |
| 669 | h.writeJSON(w, map[string]any{ |
| 670 | "success": false, |
| 671 | "error": err.Error(), |
| 672 | }) |
| 673 | return |
| 674 | } |
| 675 | |
| 676 | h.writeJSON(w, map[string]any{ |
| 677 | "success": true, |
| 678 | "message": "client started", |
| 679 | }) |
| 680 | } |
| 681 | |
| 682 | func (h *Handler) handleClientStop(w http.ResponseWriter, r *http.Request, accountID types.AccountID) { |
| 683 | client, ok := h.provider.GetClient(accountID) |