File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ import time
2
+ from codelab_adapter .core_extension import Extension
3
+
4
+
5
+ class SyncHelloWorldExtension (Extension ):
6
+ def __init__ (self ):
7
+ super ().__init__ ()
8
+ self .EXTENSION_ID = "eim"
9
+
10
+ def send_message_to_scratch (self , payload ):
11
+ message = self .message_template ()
12
+ message ["payload" ] = payload
13
+ self .publish (message )
14
+
15
+ def extension_message_handle (self , topic , payload ):
16
+ self .logger .info (f'the message payload from scratch: { payload } ' )
17
+ content = payload ["content" ]
18
+ if type (content ) == str :
19
+ content_send_to_scratch = content [::- 1 ] # 反转字符串
20
+ time .sleep (1 )
21
+ payload ["content" ] = content_send_to_scratch
22
+ self .send_message_to_scratch (payload )
23
+
24
+ def run (self ):
25
+ while self ._running :
26
+ time .sleep (1 )
27
+
28
+ export = SyncHelloWorldExtension
You can’t perform that action at this time.
0 commit comments