feat(go): add ping CLI subcommand (§4.3)
Add PingRaw to Session (session.go), runPing to the CLI dispatch (main.go), and three tests covering plain-text echo, JSON output, and missing-session-id validation (main_test.go). Default message is "ping"; gateway echo is read from DiagnosticMessage, falling back to the kind string if absent.
This commit is contained in:
@@ -580,6 +580,17 @@ func (s *Session) WriteRaw(ctx context.Context, serverHandle, itemHandle int32,
|
||||
})
|
||||
}
|
||||
|
||||
// PingRaw sends a diagnostic PING command and returns the raw reply.
|
||||
// The message is echoed back by the gateway in the reply's DiagnosticMessage field.
|
||||
func (s *Session) PingRaw(ctx context.Context, message string) (*MxCommandReply, error) {
|
||||
return s.invokeCommand(ctx, &pb.MxCommand{
|
||||
Kind: pb.MxCommandKind_MX_COMMAND_KIND_PING,
|
||||
Payload: &pb.MxCommand_Ping{
|
||||
Ping: &pb.PingCommand{Message: message},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// Write2 invokes MXAccess Write2 (timestamped single-item write).
|
||||
func (s *Session) Write2(ctx context.Context, serverHandle, itemHandle int32, value, timestampValue *MxValue, userID int32) error {
|
||||
_, err := s.Write2Raw(ctx, serverHandle, itemHandle, value, timestampValue, userID)
|
||||
|
||||
Reference in New Issue
Block a user