Giter Site home page Giter Site logo

ca4ti / amimonitor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ritchelly/amimonitor

0.0 1.0 0.0 51 KB

This is a monitor of events of asterisk AMI, and is a simple code, I will improve this code, but, its here to anyone that need.

PHP 93.32% JavaScript 6.68%

amimonitor's Introduction

amiMonitor

This is a new colaboration of asterisk AMI with PHP.

Donate

Help this project grow. Has many things to improve. Donate

Instalation

Via Composer just run composer require ritch/ami-monitor or clone this repository via Github.

Run composer install if you cloned the project by git directly

Run npm install

I Will improve this code and this explication, I swear, but if you only read this code, mainly monitorManager.php or run php monitorManager.php, You can use.

Configuration

  1. Copy the config.ini.sample to config.ini and put your configs

To Run

  1. If you want use web socket, run node webSocketServer.js, dont forget to put the configuration in config.ini.
  2. Copy samples to your base directory cp -rf vendor/ritch/ami-monitor/samples . or make your self monitor.
  3. Run php samples/monitorManager.php
  4. Has a file index.html in samples folder, if you has using web socket, and all right, you'll start receive the events on your web page.

Custom File monitor example:

<?php 

namespace App;

//The path of autoload
include 'vendor/autoload.php';

use App\WebSocket;
use App\Ami;

set_time_limit(0);

$webSocket = new WebSocket();
$ami = new Ami();

//Filter some events or show All;
$event = [
	'All',
      /*'AgentLogin',
	'Hangup',
	'BridgeEnter',
	'AgentConnect',
	*/
];

do {
    switch ( @$amiEvent->Event ) {
	//If you has filtering some event, here you can do your logic, or send to websocket,
	case "Hangup":
		// You code here.
		$amiEvent = $ami->getEvent($event);
		$webSocket->emit( "MyCustomAction", [ $amiEvent ] );
		print_r($amiEvent);
	break;

	case "AgentConnect":
		// You code here.
	break;

	default:
		$amiEvent = $ami->getEvent($event);
		$webSocket->emit( "ami", [ $amiEvent ] );
		print_r($amiEvent);
	break;
     }
}
while ( Utils::check_asterisk_status() );

?>

Donate

Help this project grow. Has many things to improve.

Donate

amimonitor's People

Contributors

ritchelly avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.