func (s *Service) HandleInbound(msg service.DIDCommMsg, didCommCtx service.DIDCommContext) (string, error) {
	logger.Debugf("inbound message: %s", msg)
	if !s.Accept(msg.Type()) {
		return "", fmt.Errorf("unsupported message type %s", msg.Type())
	}
	events := s.ActionEvent()
	if events == nil {
		return "", fmt.Errorf("no clients registered to handle action events for %s protocol", Name)
	}
	myContext, err := s.currentContext(msg, didCommCtx, nil)
	if err != nil {
		return "", fmt.Errorf("unable to load current context for msgID=%s: %w", msg.ID(), err)
	}
	if requiresApproval(msg) {
		go func() {
			s.requestApproval(myContext, events, msg)
		}()
		return "", nil
	}
	return "", s.handleContext(myContext)
}
HandleInbound handles inbound messages.
package outofband
import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/google/uuid"
	"github.com/mitchellh/mapstructure"
	"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/protocol/decorator"
	"github.com/hyperledger/aries-framework-go/pkg/didcomm/protocol/didexchange"
	"github.com/hyperledger/aries-framework-go/pkg/doc/did"
	"github.com/hyperledger/aries-framework-go/pkg/internal/logutil"
	"github.com/hyperledger/aries-framework-go/pkg/store/connection"
	"github.com/hyperledger/aries-framework-go/spi/storage"
)
const (
	Name = "out-of-band"
	PIURI = "https://didcomm.org/out-of-band/1.0"
	oldPIURI = "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.0"
	InvitationMsgType = PIURI + "/invitation"
	OldInvitationMsgType = oldPIURI + "/invitation"
	HandshakeReuseMsgType = PIURI + "/handshake-reuse"
	HandshakeReuseAcceptedMsgType = PIURI + "/handshake-reuse-accepted"
	callbackChannelSize = 10
	contextKey = "context_%s"
)
const (
	MediaTypeProfileDIDCommAIP1 = "didcomm/aip1"
	MediaTypeProfileDIDCommAIP2RFC19 = "didcomm/aip2;env=rfc19"
	MediaTypeProfileAIP2RFC587 = "didcomm/aip2;env=rfc587"
	MediaTypeProfileDIDCommV2 = "didcomm/v2"
)
var logger = log.New(fmt.Sprintf("aries-framework/%s/service", Name))
var errIgnoredDidEvent = errors.New("ignored")
type Options interface {
	MyLabel() string
	RouterConnections() []string
	ReuseAnyConnection() bool
	ReuseConnection() string
}
type didExchSvc interface {
	RespondTo(*didexchange.OOBInvitation, []string) (string, error)
	SaveInvitation(invitation *didexchange.OOBInvitation) error
}
type connectionRecorder interface {
	SaveInvitation(string, interface{}) error
	GetConnectionRecord(string) (*connection.Record, error)
	GetConnectionIDByDIDs(string, string) (string, error)
	QueryConnectionRecords() ([]*connection.Record, error)
}
type Service struct {
	service.Action
	service.Message
	callbackChannel            chan *callback
	didSvc                     didExchSvc
	didEvents                  chan service.StateMsg
	transientStore             storage.Store
	connections                connectionRecorder
	inboundHandler             func() service.InboundHandler
	chooseAttachmentFunc       func(*attachmentHandlingState) (*decorator.Attachment, error)
	extractDIDCommMsgBytesFunc func(*decorator.Attachment) ([]byte, error)
	listenerFunc               func()
	messenger                  service.Messenger
	myMediaTypeProfiles        []string
}
type callback struct {
	msg      service.DIDCommMsg
	myDID    string
	theirDID string
	ctx      *context
}
type attachmentHandlingState struct {
	ID           string
	ConnectionID string
	Invitation   *Invitation
	Done         bool
}
type Action struct {
	PIID         string
	Msg          service.DIDCommMsgMap
	ProtocolName string
	MyDID        string
	TheirDID     string
}
type context struct {
	Action
	CurrentStateName   string
	Inbound            bool
	ReuseAnyConnection bool
	ReuseConnection    string
	ConnectionID       string
	Invitation         *Invitation
	DIDExchangeInv     *didexchange.OOBInvitation
	MyLabel            string
	RouterConnections  []string
}
type Provider interface {
	Service(id string) (interface{}, error)
	StorageProvider() storage.Provider
	ProtocolStateStorageProvider() storage.Provider
	InboundDIDCommMessageHandler() func() service.InboundHandler
	Messenger() service.Messenger
	MediaTypeProfiles() []string
}
func New(p Provider) (*Service, error) {
	svc, err := p.Service(didexchange.DIDExchange)
	if err != nil {
		return nil, fmt.Errorf("failed to initialize outofband service : %w", err)
	}
	didSvc, ok := svc.(didExchSvc)
	if !ok {
		return nil, errors.New("failed to cast the didexchange service to satisfy our dependency")
	}
	store, err := p.ProtocolStateStorageProvider().OpenStore(Name)
	if err != nil {
		return nil, fmt.Errorf("failed to open the transientStore : %w", err)
	}
	err = p.ProtocolStateStorageProvider().SetStoreConfig(Name,
		storage.StoreConfiguration{TagNames: []string{contextKey}})
	if err != nil {
		return nil, fmt.Errorf("failed to set transientStore config in protocol state transientStore: %w", err)
	}
	connectionRecorder, err := connection.NewRecorder(p)
	if err != nil {
		return nil, fmt.Errorf("failed to open a connection.Lookup : %w", err)
	}
	s := &Service{
		callbackChannel:            make(chan *callback, callbackChannelSize),
		didSvc:                     didSvc,
		didEvents:                  make(chan service.StateMsg, callbackChannelSize),
		transientStore:             store,
		connections:                connectionRecorder,
		inboundHandler:             p.InboundDIDCommMessageHandler(),
		chooseAttachmentFunc:       chooseAttachment,
		extractDIDCommMsgBytesFunc: extractDIDCommMsgBytes,
		messenger:                  p.Messenger(),
		myMediaTypeProfiles:        p.MediaTypeProfiles(),
	}
	s.listenerFunc = listener(s.callbackChannel, s.didEvents, s.handleCallback, s.handleDIDEvent)
	didEventsSvc, ok := didSvc.(service.Event)
	if !ok {
		return nil, errors.New("failed to cast didexchange service to service.Event")
	}
	if err = didEventsSvc.RegisterMsgEvent(s.didEvents); err != nil {
		return nil, fmt.Errorf("failed to register for didexchange protocol msgs : %w", err)
	}
	go s.listenerFunc()
	return s, nil
}
func (s *Service) Name() string {
	return Name
}
func (s *Service) Accept(msgType string) bool {
	switch msgType {
	case InvitationMsgType, HandshakeReuseMsgType, HandshakeReuseAcceptedMsgType, OldInvitationMsgType:
		return true
	}
	return false
}