File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import asyncio
2+ from typing import TYPE_CHECKING , Any
3+
4+ from src .actions .base import ClientActionHandler , register_client_action
5+ from src .schema .frames import ClientFrame
6+
7+ if TYPE_CHECKING :
8+ from src .engine .connection_context import ConnectionContext
9+
10+
11+ @register_client_action ("ECHO" )
12+ class EchoActionHandler (ClientActionHandler ):
13+ """Example client action for testing."""
14+
15+ action_type = "ECHO"
16+ context_template = "Client sent an echo message."
17+
18+ def to_context_str (self , payload : dict [str , Any ]) -> str :
19+ message = payload .get ("message" , "" )
20+ return f"[EVENT:ECHO] Client sent an echo message: { message } "
21+
22+ async def execute (
23+ self ,
24+ frame : ClientFrame ,
25+ _ctx : "ConnectionContext" ,
26+ content_queue : asyncio .Queue [dict [str , Any ]],
27+ ) -> None :
28+ context_str = self .to_context_str (frame .payload )
29+ await content_queue .put ({"type" : "text" , "text" : context_str })
You can’t perform that action at this time.
0 commit comments