func (c *Client) RegisterService(name, msgType string, purpose ...string) error {
	return c.msgRegistrar.Register(newMessageService(name, msgType, purpose, c.notifier))
}
RegisterService registers new message service to message handler registrar.
package messaging
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"github.com/google/uuid"
	"github.com/hyperledger/aries-framework-go/pkg/common/log"
	"github.com/hyperledger/aries-framework-go/pkg/didcomm/common/service"
	"github.com/hyperledger/aries-framework-go/pkg/didcomm/dispatcher"
	"github.com/hyperledger/aries-framework-go/pkg/framework/aries/api/vdr"
	"github.com/hyperledger/aries-framework-go/pkg/kms"
	"github.com/hyperledger/aries-framework-go/pkg/store/connection"
	"github.com/hyperledger/aries-framework-go/pkg/vdr/fingerprint"
	"github.com/hyperledger/aries-framework-go/spi/storage"
)
const (
	errMsgDestinationMissing = "missing message destination"
)
var logger = log.New("aries-framework/client/messaging")
type provider interface {
	VDRegistry() vdr.Registry
	Messenger() service.Messenger
	ProtocolStateStorageProvider() storage.Provider
	StorageProvider() storage.Provider
	KMS() kms.KeyManager
}
type MessageHandler interface {
	Services() []dispatcher.MessageService
	Register(msgSvcs ...dispatcher.MessageService) error
	Unregister(name string) error
}
type Notifier interface {
	Notify(topic string, message []byte) error
}
type sendMsgOpts struct {
	connectionID string
	theirDID string
	destination *service.Destination
	responseMsgType string
	waitForResponseCtx context.Context
}
type SendMessageOpions func(opts *sendMsgOpts)
func SendByConnectionID(connectionID string) SendMessageOpions {
	return func(opts *sendMsgOpts) {
		opts.connectionID = connectionID
	}
}
func SendByTheirDID(theirDID string) SendMessageOpions {
	return func(opts *sendMsgOpts) {
		opts.theirDID = theirDID
	}
}
func SendByDestination(destination *service.Destination) SendMessageOpions {
	return func(opts *sendMsgOpts) {
		opts.destination = destination
	}
}
func WaitForResponse(ctx context.Context, responseType string) SendMessageOpions {
	return func(opts *sendMsgOpts) {
		opts.waitForResponseCtx = ctx
		opts.responseMsgType = responseType
	}
}
type messageDispatcher func() error
type Client struct {
	ctx              provider
	msgRegistrar     MessageHandler
	notifier         Notifier
	connectionLookup *connection.Lookup
}
func New(ctx provider, registrar MessageHandler, notifier Notifier) (*Client, error) {
	connectionLookup, err := connection.NewLookup(ctx)
	if err != nil {
		return nil, fmt.Errorf("failed to initialize connection lookup : %w", err)
	}
	c := &Client{
		ctx:              ctx,
		msgRegistrar:     registrar,
		connectionLookup: connectionLookup,
		notifier:         notifier,
	}
	return c, nil
}