Ping sends a ping request to the server to verify connectivity. The message parameter is optional and will be echoed back in the response. Returns a PingResponse containing the message and server timestamp, or an error. Example: resp, err := client.Ping(context.Background(), "health check") if
(ctx context.Context, message string)
| 1555 | // log.Printf("Server responded at %s", resp.Timestamp) |
| 1556 | // } |
| 1557 | func (c *Client) Ping(ctx context.Context, message string) (*PingResponse, error) { |
| 1558 | if c.client == nil { |
| 1559 | return nil, fmt.Errorf("client not connected") |
| 1560 | } |
| 1561 | |
| 1562 | result, err := c.client.Request(ctx, "ping", pingRequest{Message: message}) |
| 1563 | if err != nil { |
| 1564 | return nil, err |
| 1565 | } |
| 1566 | |
| 1567 | var response PingResponse |
| 1568 | if err := json.Unmarshal(result, &response); err != nil { |
| 1569 | return nil, err |
| 1570 | } |
| 1571 | return &response, nil |
| 1572 | } |
| 1573 | |
| 1574 | // GetStatus returns CLI status including version and protocol information |
| 1575 | func (c *Client) GetStatus(ctx context.Context) (*GetStatusResponse, error) { |