Documentation
¶
Overview ¶
Package trustping implements the DIDComm Trust Ping Protocol 2.0.
Trust Ping is used to test connectivity and verify that an agent is online and responsive.
Protocol URI: https://didcomm.org/trust-ping/2.0
Message Types ¶
- ping: Request a response from the receiver
- ping-response: Response to a ping request
Usage ¶
// Create and send a ping
ping := trustping.NewPing(
"did:example:alice",
"did:example:bob",
trustping.WithResponseRequested(true),
trustping.WithComment("Hello!"),
)
// Handle a received ping
response, err := trustping.HandlePing(msg)
Index ¶
- Constants
- func HandlePing(ping *message.Message) (*message.Message, error)
- func IsPing(msg *message.Message) bool
- func IsPingResponse(msg *message.Message) bool
- func NewPing(from, to string, opts ...PingOption) (*message.Message, error)
- func NewPingResponse(ping *message.Message, comment string) (*message.Message, error)
- func ResponseRequested(msg *message.Message) bool
- type Ping
- type PingBody
- type PingOption
- type PingResponse
- type PingResponseBody
Constants ¶
const ( // Protocol identifier ProtocolURI = "https://didcomm.org/trust-ping/2.0" // Message types TypePing = ProtocolURI + "/ping" TypePingResponse = ProtocolURI + "/ping-response" )
Variables ¶
This section is empty.
Functions ¶
func HandlePing ¶
HandlePing processes a ping message and returns a response if requested. Returns nil if no response is needed.
func IsPingResponse ¶
IsPingResponse checks if a message is a trust ping response.
func NewPing ¶
func NewPing(from, to string, opts ...PingOption) (*message.Message, error)
NewPing creates a new trust ping message.
func NewPingResponse ¶
NewPingResponse creates a response to a ping message.
func ResponseRequested ¶
ResponseRequested returns whether a ping expects a response.
Types ¶
type PingBody ¶
type PingBody struct {
// ResponseRequested indicates whether a response is expected.
// If false, the receiver should not respond.
ResponseRequested bool `json:"response_requested,omitempty"`
// Comment is an optional human-readable message.
Comment string `json:"comment,omitempty"`
}
PingBody contains the body fields for a ping message.
type PingOption ¶
type PingOption func(*pingConfig)
PingOption configures ping creation.
func WithComment ¶
func WithComment(comment string) PingOption
WithComment adds a human-readable comment.
func WithResponseRequested ¶
func WithResponseRequested(requested bool) PingOption
WithResponseRequested sets whether a response is expected.
type PingResponse ¶
PingResponse represents a trust ping response message.
type PingResponseBody ¶
type PingResponseBody struct {
// Comment is an optional human-readable message.
Comment string `json:"comment,omitempty"`
}
PingResponseBody contains the body fields for a ping response.