Skip to content

litnimax/nameko-ami

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nameko AMI client

Example of usage

from nameko.events import EventDispatcher
from nameko.dependency_providers import Config
from nameko.rpc import rpc
from nameko_ami import AmiClientExtension, ami

logger = logging.getLogger(__name__)

class AmiBroker:
    name = 'asterisk_ami'
    config = Config()
    ami_client = AmiClientExtension()
    dispatch = EventDispatcher()

    @rpc
    def send_action(self, action):
        result = self.ami_client.manager.send_action(action)        
        return {
            'headers': result.headers,
            'data': result.data,            
        }

    @ami('*')
    def on_ami_event(self, event, manager):
        if self.config.get('ASTERISK_AMI_TRACE_EVENTS'):
            logger.debug('AMI Event: %s', event.headers)
        self.dispatch(event.headers['Event'], {'headers': event.headers,
                                               'data': event.data})

Configuration parameters

  • ASTERISK_AMI_HOST
  • ASTERISK_AMI_PORT
  • ASTERISK_AMI_USER
  • ASTERISK_AMI_PASS
  • ASTERISK_AMI_TRACE_EVENTS: if set AMI entrypoint will dump every event message it receives.

About

Nameko Asterisk Manager Interface client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages