25 lines
494 B
Go
25 lines
494 B
Go
package handlers
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"overlord-client/cmd/agent/runtime"
|
|
"overlord-client/cmd/agent/wire"
|
|
"time"
|
|
)
|
|
|
|
func HandlePing(ctx context.Context, env *runtime.Env, envelope map[string]interface{}) error {
|
|
|
|
ts := extractTimestamp(envelope["ts"])
|
|
if ts == 0 {
|
|
ts = time.Now().UnixMilli()
|
|
}
|
|
pong := wire.Pong{Type: "pong", TS: ts}
|
|
if err := wire.WriteMsg(ctx, env.Conn, pong); err != nil {
|
|
log.Printf("ping: failed to send pong: %v", err)
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|