Skip to content

Commit 02818e3

Browse files
committed
feat: convert handler to a class
Signed-off-by: Colton Wolkins (Laptop) <[email protected]>
1 parent 280e715 commit 02818e3

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

acapy_agent/core/dispatcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ async def handle_v2_message(
212212
handler = context.message
213213
if self.collector:
214214
handler = self.collector.wrap_coro(handler, [handler.__qualname__])
215-
await handler(context, responder, payload=inbound_message.payload)
215+
await handler()(context, responder, payload=inbound_message.payload)
216216

217217
async def make_v2_message(self, profile: Profile, parsed_msg: dict) -> BaseMessage:
218218
"""Deserialize a message dict into the appropriate message instance.

acapy_agent/protocols_v2/trustping/v1_0/message_types.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Message type identifiers for Trust Pings."""
22

33
#from ...didcomm_prefix import DIDCommPrefix
4+
import logging
5+
from ....messaging.v2_agent_message import V2AgentMessage
46

57
SPEC_URI = (
68
"https://github.com/hyperledger/aries-rfcs/tree/"
@@ -12,11 +14,24 @@
1214
PING_RESPONSE = "trust_ping/1.0/ping_response"
1315
DEBUG = "https://didcomm.org/basicmessage/2.0/message"
1416

15-
PROTOCOL_PACKAGE = "acapy_agent.protocols.trustping.v1_0"
17+
PROTOCOL_PACKAGE = "acapy_agent.protocols_v2.trustping.v1_0"
1618

17-
def test_func(context, responder, payload):
18-
message = payload
19-
print(message)
19+
class test_func:
20+
async def __call__(self, *args, **kwargs):
21+
await self.handle(*args, **kwargs)
22+
@staticmethod
23+
async def handle(context, responder, payload):
24+
message = payload
25+
logger = logging.getLogger(__name__)
26+
error_result = V2AgentMessage(
27+
message={
28+
"type": "https://didcomm.org/basicmessage/2.0/message",
29+
"body": {
30+
"message": "Hello Frosty :3",
31+
},
32+
}
33+
)
34+
await responder.send_reply(error_result)
2035

2136
HANDLERS = {
2237
DEBUG: f"{PROTOCOL_PACKAGE}.message_types.test_func",
File renamed without changes.

0 commit comments

Comments
 (0)