feat: agregar método SendCommand al CDP client
Agrega método conveniente SendCommand() que retorna map directamente. Simplifica llamadas CDP que necesitan resultado como map en lugar de struct. Antes: Execute(ctx, method, params, &result) Ahora: SendCommand(ctx, method, params) retorna map Archivo: pkg/cdp/client.go
This commit is contained in:
@@ -204,6 +204,15 @@ func (c *Client) Execute(ctx context.Context, method string, params interface{},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SendCommand envía un comando CDP y retorna el resultado como map
|
||||||
|
func (c *Client) SendCommand(ctx context.Context, method string, params interface{}) (map[string]interface{}, error) {
|
||||||
|
var result map[string]interface{}
|
||||||
|
if err := c.Execute(ctx, method, params, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
// On registra un handler para un evento específico.
|
// On registra un handler para un evento específico.
|
||||||
func (c *Client) On(event string, handler EventHandler) {
|
func (c *Client) On(event string, handler EventHandler) {
|
||||||
c.eventMu.Lock()
|
c.eventMu.Lock()
|
||||||
|
|||||||
Reference in New Issue
Block a user