diff --git a/pkg/didcomm/dispatcher/api.go b/pkg/didcomm/dispatcher/api.go index f354fd9d44..76451505d8 100644 --- a/pkg/didcomm/dispatcher/api.go +++ b/pkg/didcomm/dispatcher/api.go @@ -16,6 +16,22 @@ type Service interface { Handle(msg DIDCommMsg) error Accept(msgType string) bool Name() string + + // RegisterActionEvent on protocol messages. The events are triggered for incoming message types based on + // the protocol service. The consumer need to invoke the callback to resume processing. + // Only one channel can be registered for the action events. The function will throw error if a channel is already + // registered. + RegisterActionEvent(ch chan<- DIDCommAction) error + + // UnregisterActionEvent on protocol messages. Refer RegisterActionEvent(). + UnregisterActionEvent(ch chan<- DIDCommAction) error + + // RegisterMsgEvent on protocol messages. The message events are triggered for incoming messages. Service + // will not expect any callback on these events unlike Action event. + RegisterMsgEvent(ch chan<- DIDCommMsg) error + + // UnregisterMsgEvent on protocol messages. Refer RegisterMsgEvent(). + UnregisterMsgEvent(ch chan<- DIDCommMsg) error } // DIDCommMsg did comm msg diff --git a/pkg/framework/aries/framework_test.go b/pkg/framework/aries/framework_test.go index a10361b0f2..65ff7b0528 100644 --- a/pkg/framework/aries/framework_test.go +++ b/pkg/framework/aries/framework_test.go @@ -351,6 +351,22 @@ func (m mockProtocolSvc) Name() string { return "mockProtocolSvc" } +func (m mockProtocolSvc) RegisterActionEvent(ch chan<- dispatcher.DIDCommAction) error { + return nil +} + +func (m mockProtocolSvc) UnregisterActionEvent(ch chan<- dispatcher.DIDCommAction) error { + return nil +} + +func (m mockProtocolSvc) RegisterMsgEvent(ch chan<- dispatcher.DIDCommMsg) error { + return nil +} + +func (m mockProtocolSvc) UnregisterMsgEvent(ch chan<- dispatcher.DIDCommMsg) error { + return nil +} + type mockTransportProviderFactory struct { err error } diff --git a/pkg/framework/context/context_test.go b/pkg/framework/context/context_test.go index a9101ee13e..e2f30716d1 100644 --- a/pkg/framework/context/context_test.go +++ b/pkg/framework/context/context_test.go @@ -171,3 +171,19 @@ func (m mockProtocolSvc) Accept(msgType string) bool { func (m mockProtocolSvc) Name() string { return "mockProtocolSvc" } + +func (m mockProtocolSvc) RegisterActionEvent(ch chan<- dispatcher.DIDCommAction) error { + return nil +} + +func (m mockProtocolSvc) UnregisterActionEvent(ch chan<- dispatcher.DIDCommAction) error { + return nil +} + +func (m mockProtocolSvc) RegisterMsgEvent(ch chan<- dispatcher.DIDCommMsg) error { + return nil +} + +func (m mockProtocolSvc) UnregisterMsgEvent(ch chan<- dispatcher.DIDCommMsg) error { + return nil +} diff --git a/pkg/internal/mock/didcomm/protocol/mock_didexchange.go b/pkg/internal/mock/didcomm/protocol/mock_didexchange.go index 70c6c44afd..2d888c0a06 100644 --- a/pkg/internal/mock/didcomm/protocol/mock_didexchange.go +++ b/pkg/internal/mock/didcomm/protocol/mock_didexchange.go @@ -28,3 +28,19 @@ func (m *MockDIDExchangeSvc) Accept(msgType string) bool { func (m *MockDIDExchangeSvc) Name() string { return "didexchange" } + +func (m *MockDIDExchangeSvc) RegisterActionEvent(ch chan<- dispatcher.DIDCommAction) error { + return nil +} + +func (m *MockDIDExchangeSvc) UnregisterActionEvent(ch chan<- dispatcher.DIDCommAction) error { + return nil +} + +func (m *MockDIDExchangeSvc) RegisterMsgEvent(ch chan<- dispatcher.DIDCommMsg) error { + return nil +} + +func (m *MockDIDExchangeSvc) UnregisterMsgEvent(ch chan<- dispatcher.DIDCommMsg) error { + return nil +} diff --git a/pkg/restapi/operation/didexchange/didexchange_test.go b/pkg/restapi/operation/didexchange/didexchange_test.go index 62391d6dc3..8b6586397b 100644 --- a/pkg/restapi/operation/didexchange/didexchange_test.go +++ b/pkg/restapi/operation/didexchange/didexchange_test.go @@ -307,6 +307,22 @@ func (m mockProtocolSvc) Name() string { return "mockProtocolSvc" } +func (m mockProtocolSvc) RegisterActionEvent(ch chan<- dispatcher.DIDCommAction) error { + return nil +} + +func (m mockProtocolSvc) UnregisterActionEvent(ch chan<- dispatcher.DIDCommAction) error { + return nil +} + +func (m mockProtocolSvc) RegisterMsgEvent(ch chan<- dispatcher.DIDCommMsg) error { + return nil +} + +func (m mockProtocolSvc) UnregisterMsgEvent(ch chan<- dispatcher.DIDCommMsg) error { + return nil +} + type mockWriter struct { failure error }