Skip to content

Commit

Permalink
Return more relevant information in the '_ping' call.
Browse files Browse the repository at this point in the history
  • Loading branch information
adewes committed Aug 11, 2021
1 parent 268a27d commit 1238e2e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion message_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package eps
import (
"fmt"
"sync"
"time"
)

type MessageBroker interface {
Expand Down Expand Up @@ -55,7 +56,12 @@ func (b *BasicMessageBroker) AddChannel(channel Channel) error {
func (b *BasicMessageBroker) handleInternalRequest(address *Address, request *Request) (*Response, error) {
switch address.Method {
case "_ping":
return &Response{Result: request.Params, Error: nil, ID: &address.ID}, nil

if ownEntry, err := b.directory.OwnEntry(); err != nil {
return nil, fmt.Errorf("error retrieving own entry: %w", err)
} else {
return &Response{Result: map[string]interface{}{"timestamp": time.Now().Format(time.RFC3339Nano), "params": request.Params, "serverInfo": ownEntry}, Error: nil, ID: &address.ID}, nil
}
}
return nil, nil
}
Expand Down

0 comments on commit 1238e2e

Please sign in to comment.