Skip to content

Commit d794329

Browse files
author
Roman Pertsev
committed
AMI: add example for md5 auth
1 parent 0bac521 commit d794329

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/md5_auth.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import logging
2+
import os
3+
4+
from panoramisk import Manager, Message
5+
6+
7+
manager = Manager(
8+
host=os.getenv('AMI_HOST', '127.0.0.1'),
9+
port=os.getenv('AMI_PORT', 5038),
10+
username=os.getenv('AMI_USERNAME', 'username'),
11+
secret=os.getenv('AMI_SECRET', 'mysecret'),
12+
auth_type='md5', # MD5 auth, no case sensitive
13+
ping_delay=10, # Delay after start
14+
ping_interval=10, # Periodically ping AMI (dead or alive)
15+
reconnect_timeout=2, # Timeout reconnect if connection lost
16+
)
17+
18+
19+
@manager.register_event('*') # Register all events
20+
async def ami_callback(mngr: Manager, msg: Message):
21+
if msg.Event == 'FullyBooted':
22+
print(msg)
23+
24+
25+
if __name__ == '__main__':
26+
logging.basicConfig(level=logging.INFO)
27+
manager.connect(run_forever=True)

0 commit comments

Comments
 (0)